7f3f609b by David LaPalomento

Use abort() when seeking

Call abort() on the active source buffer when a seek is detected. Fix tests to match new SourceBuffer usage expectations.
1 parent a5fc94d8
...@@ -357,6 +357,9 @@ var ...@@ -357,6 +357,9 @@ var
357 var currentTime = player.currentTime(); 357 var currentTime = player.currentTime();
358 player.hls.mediaIndex = getMediaIndexByTime(player.hls.media, currentTime); 358 player.hls.mediaIndex = getMediaIndexByTime(player.hls.media, currentTime);
359 359
360 // abort any segments still being decoded
361 player.hls.sourceBuffer.abort();
362
360 // cancel outstanding requests and buffer appends 363 // cancel outstanding requests and buffer appends
361 if (segmentXhr) { 364 if (segmentXhr) {
362 segmentXhr.abort(); 365 segmentXhr.abort();
......
...@@ -63,6 +63,7 @@ module('HLS', { ...@@ -63,6 +63,7 @@ module('HLS', {
63 oldSourceBuffer = window.videojs.SourceBuffer; 63 oldSourceBuffer = window.videojs.SourceBuffer;
64 window.videojs.SourceBuffer = function() { 64 window.videojs.SourceBuffer = function() {
65 this.appendBuffer = function() {}; 65 this.appendBuffer = function() {};
66 this.abort = function() {};
66 }; 67 };
67 68
68 // force native HLS to be ignored 69 // force native HLS to be ignored
...@@ -714,6 +715,7 @@ test('drops tags before the target timestamp when seeking', function() { ...@@ -714,6 +715,7 @@ test('drops tags before the target timestamp when seeking', function() {
714 this.appendBuffer = function(chunk) { 715 this.appendBuffer = function(chunk) {
715 bytes.push(chunk); 716 bytes.push(chunk);
716 }; 717 };
718 this.abort = function() {};
717 }; 719 };
718 // capture timeouts 720 // capture timeouts
719 window.setTimeout = function(callback) { 721 window.setTimeout = function(callback) {
...@@ -755,6 +757,7 @@ test('clears pending buffer updates when seeking', function() { ...@@ -755,6 +757,7 @@ test('clears pending buffer updates when seeking', function() {
755 var 757 var
756 bytes = [], 758 bytes = [],
757 callbacks = [], 759 callbacks = [],
760 aborts = 0,
758 tags = [{ pts: 0, bytes: 0 }]; 761 tags = [{ pts: 0, bytes: 0 }];
759 // mock out the parser and source buffer 762 // mock out the parser and source buffer
760 videojs.hls.SegmentParser = mockSegmentParser(tags); 763 videojs.hls.SegmentParser = mockSegmentParser(tags);
...@@ -762,6 +765,9 @@ test('clears pending buffer updates when seeking', function() { ...@@ -762,6 +765,9 @@ test('clears pending buffer updates when seeking', function() {
762 this.appendBuffer = function(chunk) { 765 this.appendBuffer = function(chunk) {
763 bytes.push(chunk); 766 bytes.push(chunk);
764 }; 767 };
768 this.abort = function() {
769 aborts++;
770 };
765 }; 771 };
766 // capture timeouts 772 // capture timeouts
767 window.setTimeout = function(callback) { 773 window.setTimeout = function(callback) {
...@@ -785,7 +791,7 @@ test('clears pending buffer updates when seeking', function() { ...@@ -785,7 +791,7 @@ test('clears pending buffer updates when seeking', function() {
785 callbacks.shift()(); 791 callbacks.shift()();
786 } 792 }
787 793
788 deepEqual(bytes, ['flv', 7], 'tags queued to be appended should be cancelled'); 794 strictEqual(1, aborts, 'aborted pending buffer');
789 }); 795 });
790 796
791 test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() { 797 test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() {
...@@ -1067,6 +1073,7 @@ test('only reloads the active media playlist', function() { ...@@ -1067,6 +1073,7 @@ test('only reloads the active media playlist', function() {
1067 videojs.mediaSources[player.currentSrc()].trigger({ 1073 videojs.mediaSources[player.currentSrc()].trigger({
1068 type: 'sourceopen' 1074 type: 'sourceopen'
1069 }); 1075 });
1076 videojs.mediaSources[player.currentSrc()].endOfStream = function() {};
1070 1077
1071 window.XMLHttpRequest = function() { 1078 window.XMLHttpRequest = function() {
1072 this.open = function(method, url) { 1079 this.open = function(method, url) {
......