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

[WIP] fix: trigger playback ready event when rendered #75

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
16 changes: 11 additions & 5 deletions src/clappr-dash-shaka-playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ class DashShakaPlayback extends HTML5Video {
}

getCurrentTime() {
return this.shakaPlayerInstance.getMediaElement().currentTime - this.seekRange.start
return this.shakaPlayerInstance
? this.shakaPlayerInstance.getMediaElement().currentTime - this.seekRange.start
: 0
}

get _startTime() {
return this.seekRange.start
}

get presentationTimeline() {
if (!this.shakaPlayerInstance) return

return this.shakaPlayerInstance.getManifest().presentationTimeline
}

Expand All @@ -99,7 +103,11 @@ class DashShakaPlayback extends HTML5Video {
}

getProgramDateTime() {
return new Date((this.presentationTimeline.getPresentationStartTime() + this.seekRange.start) * 1000)
let presentationStartTime = this.presentationTimeline
? this.presentationTimeline.getPresentationStartTime()
kslimani marked this conversation as resolved.
Show resolved Hide resolved
: null

return new Date((presentationStartTime + this.seekRange.start) * 1000)
}

_updateDvr(status) {
Expand Down Expand Up @@ -155,15 +163,13 @@ class DashShakaPlayback extends HTML5Video {
// skipping HTML5Video `_setupSrc` (on tag video)
_setupSrc () {}

// skipping ready event on video tag in favor of ready on shaka
_ready () {
// override with no-op
this.trigger(Events.PLAYBACK_READY, this.name)
}

_onShakaReady() {
this._isShakaReadyState = true
this.trigger(DashShakaPlayback.Events.SHAKA_READY)
this.trigger(Events.PLAYBACK_READY, this.name)
}

get isReady () {
Expand Down