77a68701 by Brandon Bay Committed by bc-bbay

Fixing discontinuity seek

On seeking to a discontinuity point, the buffer would not refill and
the player would stop working. This commit fixes that issue, and
adjusts the test to catch the previous failure.
1 parent 35917615
...@@ -611,12 +611,17 @@ videojs.Hls.prototype.drainBuffer = function(event) { ...@@ -611,12 +611,17 @@ videojs.Hls.prototype.drainBuffer = function(event) {
611 // until it empties before calling it when a discontinuity is 611 // until it empties before calling it when a discontinuity is
612 // next in the buffer 612 // next in the buffer
613 if (segment.discontinuity) { 613 if (segment.discontinuity) {
614 if (event.type !== 'waiting') { 614 if (event.type === 'waiting') {
615 this.sourceBuffer.abort();
616 // tell the SWF where playback is continuing in the stitched timeline
617 this.el().vjs_setProperty('currentTime', segmentOffset * 0.001);
618 } else if (event.type === 'timeupdate') {
619 return;
620 } else if (typeof offset !== 'number') {
621 //if the discontinuity is reached under normal conditions, ie not a seek,
622 //the buffer already contains data and does not need to be refilled,
615 return; 623 return;
616 } 624 }
617 this.sourceBuffer.abort();
618 // tell the SWF where playback is continuing in the stitched timeline
619 this.el().vjs_setProperty('currentTime', segmentOffset * 0.001);
620 } 625 }
621 626
622 // transmux the segment data from MP2T to FLV 627 // transmux the segment data from MP2T to FLV
......
...@@ -1186,7 +1186,7 @@ test('waits until the buffer is empty before appending bytes at a discontinuity' ...@@ -1186,7 +1186,7 @@ test('waits until the buffer is empty before appending bytes at a discontinuity'
1186 var aborts = 0, setTime, currentTime, bufferEnd; 1186 var aborts = 0, setTime, currentTime, bufferEnd;
1187 1187
1188 player.src({ 1188 player.src({
1189 src: 'disc.m3u8', 1189 src: 'discontinuity.m3u8',
1190 type: 'application/vnd.apple.mpegurl' 1190 type: 'application/vnd.apple.mpegurl'
1191 }); 1191 });
1192 openMediaSource(player); 1192 openMediaSource(player);
...@@ -1233,7 +1233,7 @@ test('clears the segment buffer on seek', function() { ...@@ -1233,7 +1233,7 @@ test('clears the segment buffer on seek', function() {
1233 videojs.Hls.SegmentParser = mockSegmentParser(tags); 1233 videojs.Hls.SegmentParser = mockSegmentParser(tags);
1234 1234
1235 player.src({ 1235 player.src({
1236 src: 'disc.m3u8', 1236 src: 'discontinuity.m3u8',
1237 type: 'application/vnd.apple.mpegurl' 1237 type: 'application/vnd.apple.mpegurl'
1238 }); 1238 });
1239 openMediaSource(player); 1239 openMediaSource(player);
...@@ -1261,14 +1261,14 @@ test('clears the segment buffer on seek', function() { ...@@ -1261,14 +1261,14 @@ test('clears the segment buffer on seek', function() {
1261 standardXHRResponse(requests.pop()); 1261 standardXHRResponse(requests.pop());
1262 1262
1263 // play to 6s to trigger the next segment request 1263 // play to 6s to trigger the next segment request
1264 currentTime = 6; 1264 currentTime = 1;
1265 bufferEnd = 10; 1265 bufferEnd = 10;
1266 player.trigger('timeupdate'); 1266 player.trigger('timeupdate');
1267 1267
1268 standardXHRResponse(requests.pop()); 1268 standardXHRResponse(requests.pop());
1269 1269
1270 // seek back to the beginning 1270 // seek to the discontinuity
1271 player.currentTime(0); 1271 player.currentTime(10);
1272 tags.push({ pts: 0, bytes: 0 }); 1272 tags.push({ pts: 0, bytes: 0 });
1273 standardXHRResponse(requests.pop()); 1273 standardXHRResponse(requests.pop());
1274 strictEqual(aborts, 1, 'aborted once for the seek'); 1274 strictEqual(aborts, 1, 'aborted once for the seek');
......