Merge pull request #545 from gesinger/firefox-update-end-on-buffer-removal
Don’t process update end until buffered value has been set
Showing
3 changed files
with
44 additions
and
2 deletions
... | @@ -21,3 +21,4 @@ env: | ... | @@ -21,3 +21,4 @@ env: |
21 | - secure: AnduYGXka5ft1x7V3SuVYqvlKLvJGhUaRNFdy4UDJr3ZVuwpQjE4TMDG8REmJIJvXfHbh4qY4N1cFSGnXkZ4bH21Xk0v9DLhsxbarKz+X2BvPgXs+Af9EQ6vLEy/5S1vMLxfT5+y+Ec5bVNGOsdUZby8Y21CRzSg6ADN9kwPGlE= | 21 | - secure: AnduYGXka5ft1x7V3SuVYqvlKLvJGhUaRNFdy4UDJr3ZVuwpQjE4TMDG8REmJIJvXfHbh4qY4N1cFSGnXkZ4bH21Xk0v9DLhsxbarKz+X2BvPgXs+Af9EQ6vLEy/5S1vMLxfT5+y+Ec5bVNGOsdUZby8Y21CRzSg6ADN9kwPGlE= |
22 | addons: | 22 | addons: |
23 | sauce_connect: true | 23 | sauce_connect: true |
24 | firefox: latest | ... | ... |
... | @@ -1229,13 +1229,20 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () { | ... | @@ -1229,13 +1229,20 @@ videojs.HlsHandler.prototype.updateEndHandler_ = function () { |
1229 | seekable, | 1229 | seekable, |
1230 | timelineUpdate; | 1230 | timelineUpdate; |
1231 | 1231 | ||
1232 | this.pendingSegment_ = null; | ||
1233 | |||
1234 | // stop here if the update errored or was aborted | 1232 | // stop here if the update errored or was aborted |
1235 | if (!segmentInfo) { | 1233 | if (!segmentInfo) { |
1236 | return; | 1234 | return; |
1237 | } | 1235 | } |
1238 | 1236 | ||
1237 | // In Firefox, the updateend event is triggered for both removing from the buffer and | ||
1238 | // adding to the buffer. To prevent this code from executing on removals, we wait for | ||
1239 | // segmentInfo to have a filled in buffered value before we continue processing. | ||
1240 | if (!segmentInfo.buffered) { | ||
1241 | return; | ||
1242 | } | ||
1243 | |||
1244 | this.pendingSegment_ = null; | ||
1245 | |||
1239 | playlist = this.playlists.media(); | 1246 | playlist = this.playlists.media(); |
1240 | segments = playlist.segments; | 1247 | segments = playlist.segments; |
1241 | currentMediaIndex = segmentInfo.mediaIndex + (segmentInfo.mediaSequence - playlist.mediaSequence); | 1248 | currentMediaIndex = segmentInfo.mediaIndex + (segmentInfo.mediaSequence - playlist.mediaSequence); | ... | ... |
... | @@ -2906,6 +2906,40 @@ test('does not download segments if preload option set to none', function() { | ... | @@ -2906,6 +2906,40 @@ test('does not download segments if preload option set to none', function() { |
2906 | equal(requests.length, 0, 'did not download any segments'); | 2906 | equal(requests.length, 0, 'did not download any segments'); |
2907 | }); | 2907 | }); |
2908 | 2908 | ||
2909 | test('does not process update end until buffered value has been set', function() { | ||
2910 | var drainBufferCallCount = 0, origDrainBuffer; | ||
2911 | |||
2912 | player.src({ | ||
2913 | src: 'master.m3u8', | ||
2914 | type: 'application/vnd.apple.mpegurl' | ||
2915 | }); | ||
2916 | origDrainBuffer = player.tech_.hls.drainBuffer; | ||
2917 | player.tech_.hls.drainBuffer = function() { | ||
2918 | drainBufferCallCount++; | ||
2919 | }; | ||
2920 | |||
2921 | openMediaSource(player); | ||
2922 | standardXHRResponse(requests.shift()); // master | ||
2923 | standardXHRResponse(requests.shift()); // media | ||
2924 | |||
2925 | equal(drainBufferCallCount, 0, 'drainBuffer not called yet'); | ||
2926 | |||
2927 | standardXHRResponse(requests.shift()); // segment | ||
2928 | |||
2929 | ok(player.tech_.hls.pendingSegment_, 'pending segment exists'); | ||
2930 | equal(drainBufferCallCount, 1, 'drainBuffer called'); | ||
2931 | |||
2932 | player.tech_.hls.sourceBuffer.trigger('updateend'); | ||
2933 | ok(player.tech_.hls.pendingSegment_, 'pending segment exists'); | ||
2934 | |||
2935 | player.tech_.hls.drainBuffer = origDrainBuffer; | ||
2936 | player.tech_.hls.drainBuffer(); | ||
2937 | ok(player.tech_.hls.pendingSegment_, 'pending segment exists'); | ||
2938 | |||
2939 | player.tech_.hls.sourceBuffer.trigger('updateend'); | ||
2940 | ok(!player.tech_.hls.pendingSegment_, 'pending segment cleared out'); | ||
2941 | }); | ||
2942 | |||
2909 | module('Buffer Inspection'); | 2943 | module('Buffer Inspection'); |
2910 | 2944 | ||
2911 | test('detects time range end-point changed by updates', function() { | 2945 | test('detects time range end-point changed by updates', function() { | ... | ... |
-
Please register or sign in to post a comment