update duration on UI
Showing
2 changed files
with
18 additions
and
1 deletions
... | @@ -284,7 +284,8 @@ | ... | @@ -284,7 +284,8 @@ |
284 | 284 | ||
285 | // the manifest is empty until the parse stream begins delivering data | 285 | // the manifest is empty until the parse stream begins delivering data |
286 | this.manifest = { | 286 | this.manifest = { |
287 | allowCache: true | 287 | allowCache: true, |
288 | totalDuration: 0 | ||
288 | }; | 289 | }; |
289 | 290 | ||
290 | // update the manifest with the m3u8 entry from the parse stream | 291 | // update the manifest with the m3u8 entry from the parse stream | ... | ... |
... | @@ -28,6 +28,7 @@ var | ... | @@ -28,6 +28,7 @@ var |
28 | 28 | ||
29 | segmentXhr, | 29 | segmentXhr, |
30 | fillBuffer, | 30 | fillBuffer, |
31 | onLoadedManifest, | ||
31 | selectPlaylist; | 32 | selectPlaylist; |
32 | 33 | ||
33 | extname = (/[^#?]*(?:\/[^#?]*\.([^#?]*))/).exec(player.currentSrc()); | 34 | extname = (/[^#?]*(?:\/[^#?]*\.([^#?]*))/).exec(player.currentSrc()); |
... | @@ -66,6 +67,20 @@ var | ... | @@ -66,6 +67,20 @@ var |
66 | player.hls.currentMediaIndex = 0; | 67 | player.hls.currentMediaIndex = 0; |
67 | }; | 68 | }; |
68 | 69 | ||
70 | onLoadedManifest = function() { | ||
71 | if(player.hls.manifest.totalDuration === 0) { | ||
72 | for(var i in player.hls.manifest.segments) { | ||
73 | var currentSegment = player.hls.manifest.segments[i]; | ||
74 | currentSegment.timeRange = {}; | ||
75 | currentSegment.timeRange.start = player.hls.manifest.totalDuration; | ||
76 | currentSegment.timeRange.end = currentSegment.timeRange.start + currentSegment.duration; | ||
77 | player.hls.manifest.totalDuration += currentSegment.duration; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | player.duration(player.hls.manifest.totalDuration); | ||
82 | }; | ||
83 | |||
69 | /** | 84 | /** |
70 | * Determines whether there is enough video data currently in the buffer | 85 | * Determines whether there is enough video data currently in the buffer |
71 | * and downloads a new segment if the buffered time is less than the goal. | 86 | * and downloads a new segment if the buffered time is less than the goal. |
... | @@ -144,6 +159,7 @@ var | ... | @@ -144,6 +159,7 @@ var |
144 | }; | 159 | }; |
145 | player.on('loadedmetadata', fillBuffer); | 160 | player.on('loadedmetadata', fillBuffer); |
146 | player.on('timeupdate', fillBuffer); | 161 | player.on('timeupdate', fillBuffer); |
162 | player.on('loadedmanifest', onLoadedManifest); | ||
147 | 163 | ||
148 | // download and process the manifest | 164 | // download and process the manifest |
149 | (function() { | 165 | (function() { | ... | ... |
-
Please register or sign in to post a comment