Skip to content

Commit

Permalink
prevent loading of HLS/Dash media source if player has already unmounted
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaloon committed Nov 10, 2018
1 parent 2544b66 commit de8d961
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class FilePlayer extends Component {
}
componentWillUnmount () {
this.removeListeners()
this._isUnmounted = true;
}
addListeners () {
const { onReady, onPlay, onPause, onEnded, onError, playsinline } = this.props
Expand Down Expand Up @@ -103,6 +104,7 @@ export class FilePlayer extends Component {
load (url) {
if (this.shouldUseHLS(url)) {
getSDK(HLS_SDK_URL, HLS_GLOBAL).then(Hls => {
if (this._isUnmounted) return
this.hls = new Hls(this.props.config.file.hlsOptions)
this.hls.on(Hls.Events.ERROR, (e, data) => {
this.props.onError(e, data, this.hls, Hls)
Expand All @@ -113,6 +115,7 @@ export class FilePlayer extends Component {
}
if (this.shouldUseDASH(url)) {
getSDK(DASH_SDK_URL, DASH_GLOBAL).then(dashjs => {
if (this._isUnmounted) return
this.dash = dashjs.MediaPlayer().create()
this.dash.initialize(this.player, url, this.props.playing)
this.dash.getDebug().setLogToBrowserConsole(false)
Expand Down

0 comments on commit de8d961

Please sign in to comment.