Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
use bind
Browse files Browse the repository at this point in the history
  • Loading branch information
squarebracket committed Aug 18, 2017
1 parent a324adb commit 63304e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/flash-source-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,16 @@ export default class FlashSourceBuffer extends videojs.EventTarget {
removeCuesFromTrack(0, Infinity, this.inbandTextTrack_);
});

this.mediaSource_.player_.tech_.on('hls-reset', this.resetHls);
let onHlsReset = this.onHlsReset_.bind(this);

this.mediaSource_.player_.tech_.on('hls-reset', onHlsReset);

this.mediaSource_.player_.tech_.hls.on('dispose', () => {
this.transmuxer_.terminate();
this.mediaSource_.player_.tech_.off('hls-reset', this.resetHls);
this.mediaSource_.player_.tech_.off('hls-reset', onHlsReset);
});
}

resetHls() {
this.transmuxer_.postMessage({action: 'resetCaptions'});
}

/**
* Append bytes to the sourcebuffers buffer, in this case we
* have to append it to swf object.
Expand Down Expand Up @@ -546,4 +544,8 @@ export default class FlashSourceBuffer extends videojs.EventTarget {

return tags;
}

onHlsReset_() {
this.transmuxer_.postMessage({action: 'resetCaptions'});
}
}
6 changes: 3 additions & 3 deletions src/html-media-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export default class HtmlMediaSource extends videojs.EventTarget {
});
};

this.onResetHls_ = () => {
this.onHlsReset_ = () => {
this.sourceBuffers.forEach((sourceBuffer) => {
if (sourceBuffer.transmuxer_) {
sourceBuffer.transmuxer_.postMessage({action: 'resetCaptions'});
Expand Down Expand Up @@ -188,7 +188,7 @@ export default class HtmlMediaSource extends videojs.EventTarget {

this.player_ = videojs(video.parentNode);

this.player_.tech_.on('hls-reset', this.onResetHls_);
this.player_.tech_.on('hls-reset', this.onHlsReset_);

if (this.player_.audioTracks && this.player_.audioTracks()) {
this.player_.audioTracks().on('change', this.updateActiveSourceBuffers_);
Expand Down Expand Up @@ -240,7 +240,7 @@ export default class HtmlMediaSource extends videojs.EventTarget {
// event handlers left to unbind anyway
if (this.player_.el_) {
this.player_.off('mediachange', this.onPlayerMediachange_);
this.player_.tech_.off('hls-reset', this.onResetHls_);
this.player_.tech_.off('hls-reset', this.onHlsReset_);
}
});
}
Expand Down

0 comments on commit 63304e9

Please sign in to comment.