25232346 by David LaPalomento

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.
1 parent 8f6de665
......@@ -467,6 +467,7 @@ var
segment = playlist.segments[mediaIndex];
event = event || {};
segmentOffset = duration(playlist, 0, mediaIndex) * 1000;
// abort() clears any data queued in the source buffer so wait
// until it empties before calling it when a discontinuity is
......@@ -476,13 +477,14 @@ var
return;
}
player.hls.sourceBuffer.abort();
// tell the SWF where playback is continuing in the stitched timeline
player.hls.el().vjs_setProperty('currentTime', segmentOffset * 0.001);
}
// if we're refilling the buffer after a seek, scan through the muxed
// FLV tags until we find the one that is closest to the desired
// playback time
if (typeof offset === 'number') {
segmentOffset = duration(playlist, 0, mediaIndex) * 1000;
ptsTime = offset - segmentOffset + tags[0].pts;
while (tags[i].pts < ptsTime) {
......
......@@ -1051,7 +1051,7 @@ test('does not break if the playlist has no segments', function() {
});
test('waits until the buffer is empty before appending bytes at a discontinuity', function() {
var aborts = 0, currentTime, bufferEnd;
var aborts = 0, setTime, currentTime, bufferEnd;
player.src({
src: 'disc.m3u8',
......@@ -1067,6 +1067,11 @@ test('waits until the buffer is empty before appending bytes at a discontinuity'
player.hls.sourceBuffer.abort = function() {
aborts++;
};
player.hls.el().vjs_setProperty = function(name, value) {
if (name === 'currentTime') {
return setTime = value;
}
};
requests.pop().respond(200, null,
'#EXTM3U\n' +
......@@ -1089,6 +1094,7 @@ test('waits until the buffer is empty before appending bytes at a discontinuity'
// pretend the buffer has emptied
player.trigger('waiting');
strictEqual(aborts, 1, 'aborted before appending the new segment');
strictEqual(setTime, 10, 'updated the time after crossing the discontinuity');
});
test('clears the segment buffer on seek', function() {
......