Browse Source

fix: remove player props on dispose to stop middleware (#229)

pull/306/head
Brandon Casey 7 years ago
committed by Joe Forbes
parent
commit
cd13f9fdbe
  1. 7
      src/mse/html-media-source.js
  2. 16
      src/videojs-http-streaming.js
  3. 19
      test/test-helpers.js
  4. 2
      test/videojs-http-streaming.test.js

7
src/mse/html-media-source.js

@ -196,6 +196,10 @@ export default class HtmlMediaSource extends videojs.EventTarget {
this.player_ = videojs(video.parentNode);
if (!this.player_) {
return;
}
// hls-reset is fired by videojs.Hls on to the tech after the main SegmentLoader
// resets its state and flushes the buffer
this.player_.tech_.on('hls-reset', this.onHlsReset_);
@ -252,6 +256,9 @@ export default class HtmlMediaSource extends videojs.EventTarget {
// event handlers left to unbind anyway
if (this.player_.el_) {
this.player_.off('mediachange', this.onPlayerMediachange_);
}
if (this.player_.tech_ && this.player_.tech_.el_) {
this.player_.tech_.off('hls-reset', this.onHlsReset_);
this.player_.tech_.off('hls-segment-time-mapping', this.onHlsSegmentTimeMapping_);
}

16
src/videojs-http-streaming.js

@ -325,7 +325,8 @@ class HlsHandler extends Component {
videojs.log.warn('player.hls is deprecated. Use player.tech().hls instead.');
tech.trigger({ type: 'usage', name: 'hls-player-access' });
return this;
}
},
configurable: true
});
}
@ -337,6 +338,8 @@ class HlsHandler extends Component {
_player.vhs = this;
// deprecated, for backwards compatibility
_player.dash = this;
this.player_ = _player;
}
this.tech_ = tech;
@ -736,6 +739,17 @@ class HlsHandler extends Component {
if (this.qualityLevels_) {
this.qualityLevels_.dispose();
}
if (this.player_) {
delete this.player_.vhs;
delete this.player_.dash;
delete this.player_.hls;
}
if (this.tech_ && this.tech_.hls) {
delete this.tech_.hls;
}
super.dispose();
}

19
test/test-helpers.js

@ -310,15 +310,16 @@ export const openMediaSource = function(player, clock) {
// mock the tech *after* it has finished loading so that we don't
// mock a tech that will be unloaded on the next tick
mockTech(player.tech_);
player.tech_.hls.xhr = xhrFactory();
// simulate the sourceopen event
player.tech_.hls.mediaSource.readyState = 'open';
player.tech_.hls.mediaSource.dispatchEvent({
type: 'sourceopen',
swfId: player.tech_.el().id
});
clock.tick(1);
if (player.tech_.hls) {
player.tech_.hls.xhr = xhrFactory();
// simulate the sourceopen event
player.tech_.hls.mediaSource.readyState = 'open';
player.tech_.hls.mediaSource.dispatchEvent({
type: 'sourceopen',
swfId: player.tech_.el() && player.tech_.el().id
});
clock.tick(1);
}
};
export const standardXHRResponse = function(request, data) {

2
test/videojs-http-streaming.test.js

@ -2882,6 +2882,7 @@ QUnit.test('configures eme if present on selectedinitialmedia', function(assert)
}
};
this.player.tech_.hls.masterPlaylistController_.mediaTypes_ = {
SUBTITLES: {},
AUDIO: {
activePlaylistLoader: {
media: () => {
@ -2941,6 +2942,7 @@ QUnit.test('does not set source keySystems if keySystems not provided by source'
}
};
this.player.tech_.hls.masterPlaylistController_.mediaTypes_ = {
SUBTITLES: {},
AUDIO: {
activePlaylistLoader: {
media: () => {

Loading…
Cancel
Save