Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Not reload playlist every ms
  • Loading branch information
MBthomasgalland committed Mar 21, 2013
1 parent 826a365 commit 9e0938a
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/hlsdump.js
Expand Up @@ -96,6 +96,8 @@ var Hlsdump = function (parameters, callback) {
Hlsdump.prototype._parsePlaylist = function (playlist) {
var self = this,
i,
j,
targetDuration = 2,
diff = null,
newDiff = null,
playlistItem,
Expand Down Expand Up @@ -148,14 +150,25 @@ var Hlsdump = function (parameters, callback) {
self.emit('error', new Error("Can't download inf file " + err));
} else {
if (self.duration === null || self.duration > self.downloaded_duration) {
playlist.get(function (err, newPlaylist, item) {
if (err !== null) {
self.emit('error', new Error("Can't getting playlist " + err));
} else {
newPlaylist.parent = playlist.id;
self.emit("playlist", newPlaylist);

for (j in playlist.items) {
if (playlist.items.hasOwnProperty(j)) {
if (playlist.items[j].type === 'target_duration') {
targetDuration = playlist.items[j].duration;
}
}
});
}

setTimeout(function (playlist, self) {
playlist.get(function (err, newPlaylist, item) {
if (err !== null) {
self.emit('error', new Error("Can't getting playlist " + err));
} else {
newPlaylist.parent = playlist.id;
self.emit("playlist", newPlaylist);
}
});
}, targetDuration * 1000, playlist, self);
} else {
self.emit('downloaded', self.downloaded_files);
}
Expand Down

0 comments on commit 9e0938a

Please sign in to comment.