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
var currentTime = player.currentTime();
player.hls.mediaIndex = getMediaIndexByTime(player.hls.media, currentTime);
// abort any segments still being decoded
player.hls.sourceBuffer.abort();
// cancel outstanding requests and buffer appends
if (segmentXhr) {
segmentXhr.abort();
......
......@@ -63,6 +63,7 @@ module('HLS', {
oldSourceBuffer = window.videojs.SourceBuffer;
window.videojs.SourceBuffer = function() {
this.appendBuffer = function() {};
this.abort = function() {};
};
// force native HLS to be ignored
......@@ -714,6 +715,7 @@ test('drops tags before the target timestamp when seeking', function() {
this.appendBuffer = function(chunk) {
bytes.push(chunk);
};
this.abort = function() {};
};
// capture timeouts
window.setTimeout = function(callback) {
......@@ -755,6 +757,7 @@ test('clears pending buffer updates when seeking', function() {
var
bytes = [],
callbacks = [],
aborts = 0,
tags = [{ pts: 0, bytes: 0 }];
// mock out the parser and source buffer
videojs.hls.SegmentParser = mockSegmentParser(tags);
......@@ -762,6 +765,9 @@ test('clears pending buffer updates when seeking', function() {
this.appendBuffer = function(chunk) {
bytes.push(chunk);
};
this.abort = function() {
aborts++;
};
};
// capture timeouts
window.setTimeout = function(callback) {
......@@ -785,7 +791,7 @@ test('clears pending buffer updates when seeking', function() {
callbacks.shift()();
}
deepEqual(bytes, ['flv', 7], 'tags queued to be appended should be cancelled');
strictEqual(1, aborts, 'aborted pending buffer');
});
test('playlist 404 should trigger MEDIA_ERR_NETWORK', function() {
......@@ -1067,6 +1073,7 @@ test('only reloads the active media playlist', function() {
videojs.mediaSources[player.currentSrc()].trigger({
type: 'sourceopen'
});
videojs.mediaSources[player.currentSrc()].endOfStream = function() {};
window.XMLHttpRequest = function() {
this.open = function(method, url) {
......