f7098468 by Tom Johnson

update duration on UI

1 parent f20f58f7
......@@ -284,7 +284,8 @@
// the manifest is empty until the parse stream begins delivering data
this.manifest = {
allowCache: true
allowCache: true,
totalDuration: 0
};
// update the manifest with the m3u8 entry from the parse stream
......
......@@ -28,6 +28,7 @@ var
segmentXhr,
fillBuffer,
onLoadedManifest,
selectPlaylist;
extname = (/[^#?]*(?:\/[^#?]*\.([^#?]*))/).exec(player.currentSrc());
......@@ -66,6 +67,20 @@ var
player.hls.currentMediaIndex = 0;
};
onLoadedManifest = function() {
if(player.hls.manifest.totalDuration === 0) {
for(var i in player.hls.manifest.segments) {
var currentSegment = player.hls.manifest.segments[i];
currentSegment.timeRange = {};
currentSegment.timeRange.start = player.hls.manifest.totalDuration;
currentSegment.timeRange.end = currentSegment.timeRange.start + currentSegment.duration;
player.hls.manifest.totalDuration += currentSegment.duration;
}
}
player.duration(player.hls.manifest.totalDuration);
};
/**
* Determines whether there is enough video data currently in the buffer
* and downloads a new segment if the buffered time is less than the goal.
......@@ -144,6 +159,7 @@ var
};
player.on('loadedmetadata', fillBuffer);
player.on('timeupdate', fillBuffer);
player.on('loadedmanifest', onLoadedManifest);
// download and process the manifest
(function() {
......