Skip to content

Commit

Permalink
Merge pull request #1532 from joaopaulovieira/master
Browse files Browse the repository at this point in the history
Manage _ready() state on HLS playback
  • Loading branch information
towerz committed Nov 10, 2017
2 parents bdcbb4b + 496f6b6 commit 19ecbda
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions src/playbacks/hls/hls.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ export default class HLS extends HTML5VideoPlayback {
get name() { return 'hls' }

get levels() { return this._levels || [] }

get currentLevel() {
if (this._currentLevel === null || this._currentLevel === undefined) {
return AUTO
} else {
return this._currentLevel //0 is a valid level ID
}
}

get isReady() {
return this._isReadyState
}

set currentLevel(id) {
this._currentLevel = id
this.trigger(Events.PLAYBACK_LEVEL_SWITCH_START)
Expand Down Expand Up @@ -140,7 +146,7 @@ export default class HLS extends HTML5VideoPlayback {
this._startTimeUpdateTimer()
}

_setupHls() {
_setup() {
this._ccIsSetup = false
this._ccTracksUpdated = false
this._hls = new HLSJS(this.options.playback.hlsjsConfig || {})
Expand All @@ -153,6 +159,15 @@ export default class HLS extends HTML5VideoPlayback {
this._hls.on(HLSJS.Events.SUBTITLE_TRACK_LOADED, (evt, data) => this._onSubtitleLoaded(evt, data))
this._hls.on(HLSJS.Events.SUBTITLE_TRACKS_UPDATED, () => this._ccTracksUpdated = true)
this._hls.attachMedia(this.el)
this._ready()
}

_ready() {
if (!this._hls) {
return
}
this._isReadyState = true
this.trigger(Events.PLAYBACK_READY, this.name)
}

_recover(evt, data) {
Expand Down Expand Up @@ -338,7 +353,7 @@ export default class HLS extends HTML5VideoPlayback {

play() {
if (!this._hls) {
this._setupHls()
this._setup()
}
super.play()
}
Expand Down
4 changes: 2 additions & 2 deletions test/playbacks/hls_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('HLS playback', () => {
}
}
const playback = new HLS(options)
playback._setupHls()
playback._setup()
expect(playback._hls.config.someHlsjsOption).to.be.equal('value')
expect(playback._hls.config).not.to.include.keys('hlsMinimumDvrSize')
})
Expand All @@ -62,7 +62,7 @@ describe('HLS playback', () => {
}
}
const playback = new HLS(options)
playback._setupHls()
playback._setup()
expect(playback._hls.config.someHlsjsOption).to.be.equal('value')
expect(playback._hls.config).not.to.include.keys('hlsMinimumDvrSize')
})
Expand Down

0 comments on commit 19ecbda

Please sign in to comment.