64891846 by David LaPalomento

Merge pull request #545 from gesinger/firefox-update-end-on-buffer-removal

Don’t process update end until buffered value has been set
2 parents 2722c820 c91eb79f
......@@ -21,3 +21,4 @@ env:
- secure: AnduYGXka5ft1x7V3SuVYqvlKLvJGhUaRNFdy4UDJr3ZVuwpQjE4TMDG8REmJIJvXfHbh4qY4N1cFSGnXkZ4bH21Xk0v9DLhsxbarKz+X2BvPgXs+Af9EQ6vLEy/5S1vMLxfT5+y+Ec5bVNGOsdUZby8Y21CRzSg6ADN9kwPGlE=
addons:
sauce_connect: true
firefox: latest
......
......@@ -1229,13 +1229,20 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () {
seekable,
timelineUpdate;
this.pendingSegment_ = null;
// stop here if the update errored or was aborted
if (!segmentInfo) {
return;
}
// In Firefox, the updateend event is triggered for both removing from the buffer and
// adding to the buffer. To prevent this code from executing on removals, we wait for
// segmentInfo to have a filled in buffered value before we continue processing.
if (!segmentInfo.buffered) {
return;
}
this.pendingSegment_ = null;
playlist = this.playlists.media();
segments = playlist.segments;
currentMediaIndex = segmentInfo.mediaIndex + (segmentInfo.mediaSequence - playlist.mediaSequence);
......
......@@ -2906,6 +2906,40 @@ test('does not download segments if preload option set to none', function() {
equal(requests.length, 0, 'did not download any segments');
});
test('does not process update end until buffered value has been set', function() {
var drainBufferCallCount = 0, origDrainBuffer;
player.src({
src: 'master.m3u8',
type: 'application/vnd.apple.mpegurl'
});
origDrainBuffer = player.tech_.hls.drainBuffer;
player.tech_.hls.drainBuffer = function() {
drainBufferCallCount++;
};
openMediaSource(player);
standardXHRResponse(requests.shift()); // master
standardXHRResponse(requests.shift()); // media
equal(drainBufferCallCount, 0, 'drainBuffer not called yet');
standardXHRResponse(requests.shift()); // segment
ok(player.tech_.hls.pendingSegment_, 'pending segment exists');
equal(drainBufferCallCount, 1, 'drainBuffer called');
player.tech_.hls.sourceBuffer.trigger('updateend');
ok(player.tech_.hls.pendingSegment_, 'pending segment exists');
player.tech_.hls.drainBuffer = origDrainBuffer;
player.tech_.hls.drainBuffer();
ok(player.tech_.hls.pendingSegment_, 'pending segment exists');
player.tech_.hls.sourceBuffer.trigger('updateend');
ok(!player.tech_.hls.pendingSegment_, 'pending segment cleared out');
});
module('Buffer Inspection');
test('detects time range end-point changed by updates', function() {
......