Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update HLS and DASH SDK to use latest versions #513

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/ReactPlayer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ReactPlayer.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/players/FilePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const IOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigato
const AUDIO_EXTENSIONS = /\.(m4a|mp4a|mpga|mp2|mp2a|mp3|m2a|m3a|wav|weba|aac|oga|spx)($|\?)/i
const VIDEO_EXTENSIONS = /\.(mp4|og[gv]|webm|mov|m4v)($|\?)/i
const HLS_EXTENSIONS = /\.(m3u8)($|\?)/i
const HLS_SDK_URL = 'https://cdnjs.cloudflare.com/ajax/libs/hls.js/0.9.1/hls.min.js'
const HLS_SDK_URL = 'https://cdn.jsdelivr.net/npm/hls.js@latest'
const HLS_GLOBAL = 'Hls'
const DASH_EXTENSIONS = /\.(mpd)($|\?)/i
const DASH_SDK_URL = 'https://cdnjs.cloudflare.com/ajax/libs/dashjs/2.6.5/dash.all.min.js'
const DASH_SDK_URL = 'https://cdn.dashjs.org/latest/dash.all.min.js'
const DASH_GLOBAL = 'dashjs'
const MATCH_DROPBOX_URL = /www\.dropbox\.com\/.+/

Expand Down 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