Merge pull request #153 from videojs/gutworth-dispose-sb
Abort the SourceBuffer when the player is disposed.
Showing
2 changed files
with
20 additions
and
0 deletions
... | @@ -244,6 +244,9 @@ videojs.Hls.prototype.dispose = function() { | ... | @@ -244,6 +244,9 @@ videojs.Hls.prototype.dispose = function() { |
244 | if (this.playlists) { | 244 | if (this.playlists) { |
245 | this.playlists.dispose(); | 245 | this.playlists.dispose(); |
246 | } | 246 | } |
247 | if (this.sourceBuffer) { | ||
248 | this.sourceBuffer.abort(); | ||
249 | } | ||
247 | videojs.Flash.prototype.dispose.call(this); | 250 | videojs.Flash.prototype.dispose.call(this); |
248 | }; | 251 | }; |
249 | 252 | ... | ... |
... | @@ -1126,6 +1126,22 @@ test('disposes the playlist loader', function() { | ... | @@ -1126,6 +1126,22 @@ test('disposes the playlist loader', function() { |
1126 | strictEqual(disposes, 1, 'disposed playlist loader'); | 1126 | strictEqual(disposes, 1, 'disposed playlist loader'); |
1127 | }); | 1127 | }); |
1128 | 1128 | ||
1129 | test('aborts the source buffer on disposal', function() { | ||
1130 | var aborts = 0, player; | ||
1131 | player = createPlayer(); | ||
1132 | player.src({ | ||
1133 | src: 'manifest/master.m3u8', | ||
1134 | type: 'application/vnd.apple.mpegurl' | ||
1135 | }); | ||
1136 | openMediaSource(player); | ||
1137 | player.hls.sourceBuffer.abort = function() { | ||
1138 | aborts++; | ||
1139 | }; | ||
1140 | |||
1141 | player.dispose(); | ||
1142 | strictEqual(aborts, 1, 'aborted the source buffer'); | ||
1143 | }); | ||
1144 | |||
1129 | test('only supports HLS MIME types', function() { | 1145 | test('only supports HLS MIME types', function() { |
1130 | ok(videojs.Hls.canPlaySource({ | 1146 | ok(videojs.Hls.canPlaySource({ |
1131 | type: 'aPplicatiOn/x-MPegUrl' | 1147 | type: 'aPplicatiOn/x-MPegUrl' |
... | @@ -1687,6 +1703,7 @@ test('treats invalid keys as a key request failure', function() { | ... | @@ -1687,6 +1703,7 @@ test('treats invalid keys as a key request failure', function() { |
1687 | this.appendBuffer = function(chunk) { | 1703 | this.appendBuffer = function(chunk) { |
1688 | bytes.push(chunk); | 1704 | bytes.push(chunk); |
1689 | }; | 1705 | }; |
1706 | this.abort = function() {}; | ||
1690 | }; | 1707 | }; |
1691 | player.src({ | 1708 | player.src({ |
1692 | src: 'https://example.com/media.m3u8', | 1709 | src: 'https://example.com/media.m3u8', | ... | ... |
-
Please register or sign in to post a comment