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

Commit

Permalink
Guard against older versions of Video.js that may not not have an `au…
Browse files Browse the repository at this point in the history
…dioTracks` property on the player (#89)
  • Loading branch information
imbcmdth authored and dmlap committed May 23, 2016
1 parent 86a5623 commit fbc7043
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/html-media-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ export default class HtmlMediaSource extends videojs.EventTarget {

this.player_ = videojs(video.parentNode);

this.player_.audioTracks().on('change', this.updateActiveSourceBuffers_);
this.player_.audioTracks().on('addtrack', this.updateActiveSourceBuffers_);
this.player_.audioTracks().on('removetrack', this.updateActiveSourceBuffers_);
if (this.player_.audioTracks && this.player_.audioTracks()) {
this.player_.audioTracks().on('change', this.updateActiveSourceBuffers_);
this.player_.audioTracks().on('addtrack', this.updateActiveSourceBuffers_);
this.player_.audioTracks().on('removetrack', this.updateActiveSourceBuffers_);
}
});

// explicitly terminate any WebWorkers that were created
Expand All @@ -189,10 +191,11 @@ export default class HtmlMediaSource extends videojs.EventTarget {
return;
}

this.player_.audioTracks().off('change', this.updateActiveSourceBuffers_);
this.player_.audioTracks().off('addtrack', this.updateActiveSourceBuffers_);
this.player_.audioTracks().off('removetrack', this.updateActiveSourceBuffers_);

if (this.player_.audioTracks && this.player_.audioTracks()) {
this.player_.audioTracks().off('change', this.updateActiveSourceBuffers_);
this.player_.audioTracks().off('addtrack', this.updateActiveSourceBuffers_);
this.player_.audioTracks().off('removetrack', this.updateActiveSourceBuffers_);
}
});
}

Expand Down

0 comments on commit fbc7043

Please sign in to comment.