Update the currentTime when crossing a discontinuity
We have to call abort() before crossing a discontinuity, which resets the currentTime to zero. Reset the current time to the appropriate value for the segment after appending.
Showing
2 changed files
with
10 additions
and
2 deletions
... | @@ -467,6 +467,7 @@ var | ... | @@ -467,6 +467,7 @@ var |
467 | segment = playlist.segments[mediaIndex]; | 467 | segment = playlist.segments[mediaIndex]; |
468 | 468 | ||
469 | event = event || {}; | 469 | event = event || {}; |
470 | segmentOffset = duration(playlist, 0, mediaIndex) * 1000; | ||
470 | 471 | ||
471 | // abort() clears any data queued in the source buffer so wait | 472 | // abort() clears any data queued in the source buffer so wait |
472 | // until it empties before calling it when a discontinuity is | 473 | // until it empties before calling it when a discontinuity is |
... | @@ -476,13 +477,14 @@ var | ... | @@ -476,13 +477,14 @@ var |
476 | return; | 477 | return; |
477 | } | 478 | } |
478 | player.hls.sourceBuffer.abort(); | 479 | player.hls.sourceBuffer.abort(); |
480 | // tell the SWF where playback is continuing in the stitched timeline | ||
481 | player.hls.el().vjs_setProperty('currentTime', segmentOffset * 0.001); | ||
479 | } | 482 | } |
480 | 483 | ||
481 | // if we're refilling the buffer after a seek, scan through the muxed | 484 | // if we're refilling the buffer after a seek, scan through the muxed |
482 | // FLV tags until we find the one that is closest to the desired | 485 | // FLV tags until we find the one that is closest to the desired |
483 | // playback time | 486 | // playback time |
484 | if (typeof offset === 'number') { | 487 | if (typeof offset === 'number') { |
485 | segmentOffset = duration(playlist, 0, mediaIndex) * 1000; | ||
486 | ptsTime = offset - segmentOffset + tags[0].pts; | 488 | ptsTime = offset - segmentOffset + tags[0].pts; |
487 | 489 | ||
488 | while (tags[i].pts < ptsTime) { | 490 | while (tags[i].pts < ptsTime) { | ... | ... |
... | @@ -1051,7 +1051,7 @@ test('does not break if the playlist has no segments', function() { | ... | @@ -1051,7 +1051,7 @@ test('does not break if the playlist has no segments', function() { |
1051 | }); | 1051 | }); |
1052 | 1052 | ||
1053 | test('waits until the buffer is empty before appending bytes at a discontinuity', function() { | 1053 | test('waits until the buffer is empty before appending bytes at a discontinuity', function() { |
1054 | var aborts = 0, currentTime, bufferEnd; | 1054 | var aborts = 0, setTime, currentTime, bufferEnd; |
1055 | 1055 | ||
1056 | player.src({ | 1056 | player.src({ |
1057 | src: 'disc.m3u8', | 1057 | src: 'disc.m3u8', |
... | @@ -1067,6 +1067,11 @@ test('waits until the buffer is empty before appending bytes at a discontinuity' | ... | @@ -1067,6 +1067,11 @@ test('waits until the buffer is empty before appending bytes at a discontinuity' |
1067 | player.hls.sourceBuffer.abort = function() { | 1067 | player.hls.sourceBuffer.abort = function() { |
1068 | aborts++; | 1068 | aborts++; |
1069 | }; | 1069 | }; |
1070 | player.hls.el().vjs_setProperty = function(name, value) { | ||
1071 | if (name === 'currentTime') { | ||
1072 | return setTime = value; | ||
1073 | } | ||
1074 | }; | ||
1070 | 1075 | ||
1071 | requests.pop().respond(200, null, | 1076 | requests.pop().respond(200, null, |
1072 | '#EXTM3U\n' + | 1077 | '#EXTM3U\n' + |
... | @@ -1089,6 +1094,7 @@ test('waits until the buffer is empty before appending bytes at a discontinuity' | ... | @@ -1089,6 +1094,7 @@ test('waits until the buffer is empty before appending bytes at a discontinuity' |
1089 | // pretend the buffer has emptied | 1094 | // pretend the buffer has emptied |
1090 | player.trigger('waiting'); | 1095 | player.trigger('waiting'); |
1091 | strictEqual(aborts, 1, 'aborted before appending the new segment'); | 1096 | strictEqual(aborts, 1, 'aborted before appending the new segment'); |
1097 | strictEqual(setTime, 10, 'updated the time after crossing the discontinuity'); | ||
1092 | }); | 1098 | }); |
1093 | 1099 | ||
1094 | test('clears the segment buffer on seek', function() { | 1100 | test('clears the segment buffer on seek', function() { | ... | ... |
-
Please register or sign in to post a comment