Permalink
Browse files

Remove duration property from the Playlist model. Always update Track…

… duration during loading/playback, not just for external sources.
  • Loading branch information...
1 parent 15c00d8 commit 9a1d2569f398286ab7e6eae3f30c6bada206cbe2 @jwheare committed Dec 15, 2009
Showing with 4 additions and 27 deletions.
  1. +2 −4 src/js/main/playdar.js
  2. +1 −21 src/js/models/playlist.model.js
  3. +1 −2 src/js/models/playlisttrack.model.js
View
@@ -304,7 +304,7 @@ var PLAYDAR = {
// Not called when served from cache
onResultLoad: function () {
- if (this.options.external && this.duration) {
+ if (this.duration) {
PLAYDAR.updateStreamDuration(this.sID, this.duration);
}
var trackSource = $('#' + this.sID);
@@ -508,9 +508,7 @@ var PLAYDAR = {
var loaded = this.bytesLoaded/this.bytesTotal * 100;
loading.width(loaded + "%");
}
- if (this.options.external) {
- PLAYDAR.updateStreamDuration(this.sID, this.durationEstimate, loaded < 100);
- }
+ PLAYDAR.updateStreamDuration(this.sID, this.durationEstimate, loaded < 100);
},
updateStreamDuration: function (sid, duration, estimate) {
var track_item = $('#' + sid).data('track_item');
@@ -1,13 +1,12 @@
/**
* class MODELS.Playlist
- * Playlist objects have a name, array of Tracks and duration
+ * Playlist objects have an array of PlaylistTracks, and associated metadata
**/
function Playlist (options) {
this.saved = false;
this.persisted = false;
this.published = false;
this.tracks = [];
- this.duration = 0;
this.options = options || {};
@@ -74,24 +73,6 @@ Playlist.prototype = {
// AUTOSAVE
this.save();
},
- update_duration: function () {
- var duration = 0;
- $.each(this.tracks, function (i, playlist_track) {
- if (playlist_track.track.duration) {
- duration += playlist_track.track.duration;
- }
- });
- this.set_duration(duration);
- },
- set_duration: function (duration) {
- this.duration = duration;
- if (this.options.onSetDuration) {
- this.options.onSetDuration.call(this);
- }
- },
- get_duration: function () {
- return Playdar.Util.mmss(this.duration);
- },
toString: function () {
return this.name;
},
@@ -314,7 +295,6 @@ Playlist.prototype = {
published: this.published,
type: 'playlist',
name: this.name,
- duration: this.duration,
image: this.image,
subtitle: this.subtitle,
description: this.description,
@@ -33,14 +33,13 @@ PlaylistTrack.prototype = {
set_track_duration: function (duration) {
if (duration) {
this.track.duration = duration;
- this.playlist.update_duration();
}
},
/**
* Build a DOMElement for the PlaylistTrack
**/
set_element: function (element_name) {
- var element_name = element_name || 'li';
+ element_name = element_name || 'li';
this.element = $('<' + element_name + ' class="p_t">')
.attr('id', this.get_dom_id())
.data('playlist_track', this)

0 comments on commit 9a1d256

Please sign in to comment.