Skip to content

Commit

Permalink
Merge pull request #88 from clappr/feature/avoid-exceptions-pre-play
Browse files Browse the repository at this point in the history
Avoid exceptions due to undefined shakaPlayer
  • Loading branch information
jhonatangcavalcanti authored Dec 1, 2020
2 parents d6a3ee0 + 8ec74a1 commit 095c3dc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/clappr-dash-shaka-playback.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class DashShakaPlayback extends HTML5Video {
}

get seekRange() {
if (!this.shakaPlayerInstance) return { start: 0, end: 0}

return this.shakaPlayerInstance.seekRange()
}

Expand Down Expand Up @@ -75,6 +77,8 @@ class DashShakaPlayback extends HTML5Video {
}

getCurrentTime() {
if (!this.shakaPlayerInstance) return 0

return this.shakaPlayerInstance.getMediaElement().currentTime - this.seekRange.start
}

Expand All @@ -83,6 +87,8 @@ class DashShakaPlayback extends HTML5Video {
}

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

return this.shakaPlayerInstance.getManifest().presentationTimeline
}

Expand All @@ -101,6 +107,8 @@ class DashShakaPlayback extends HTML5Video {
}

getProgramDateTime() {
if (!this.shakaPlayerInstance) return 0

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

Expand Down

0 comments on commit 095c3dc

Please sign in to comment.