diff --git a/lib/media/playhead.js b/lib/media/playhead.js index 59d49edde..b5177d5a7 100644 --- a/lib/media/playhead.js +++ b/lib/media/playhead.js @@ -143,10 +143,12 @@ shaka.media.Playhead.prototype.getStartTime_ = function() { var startTime; if (this.timeline_.getDuration() < Number.POSITIVE_INFINITY) { + // If the presentation is VOD, or if the presentation is live but has + // finished broadcasting, then start from the beginning. startTime = this.timeline_.getSegmentAvailabilityStart(); } else { - // For live presentations, ensure that the startup buffering goal can be - // met. + // Otherwise, start near the live-edge, but ensure that the startup + // buffering goal can be met startTime = Math.max( this.timeline_.getSegmentAvailabilityEnd() - this.rebufferingGoal_, this.timeline_.getSegmentAvailabilityStart()); @@ -277,13 +279,14 @@ shaka.media.Playhead.prototype.onSeeking_ = function() { */ shaka.media.Playhead.prototype.reposition_ = function(currentTime) { var availabilityDuration = this.timeline_.getSegmentAvailabilityDuration(); - var live = (availabilityDuration != null) && - (availabilityDuration < Number.POSITIVE_INFINITY); - var start = this.timeline_.getSegmentAvailabilityStart(); var end = this.timeline_.getSegmentAvailabilityEnd(); - if (!live) { + if (availabilityDuration == null || + availabilityDuration == Number.POSITIVE_INFINITY) { + // If the presentation is live but has an infinite segment availability + // duration then we can treat it as VOD since the start of the seek range + // is not moving. if (currentTime < start) { shaka.log.v1('Seek before start.'); return start; diff --git a/lib/player.js b/lib/player.js index e0c6edeb9..4815ee96e 100644 --- a/lib/player.js +++ b/lib/player.js @@ -634,8 +634,10 @@ shaka.Player.prototype.getNetworkingEngine = function() { */ shaka.Player.prototype.isLive = function() { if (!this.manifest_) return false; + + // If the presentation has a segment availability window then it's live. var timeline = this.manifest_.presentationTimeline; - return timeline.getDuration() == Number.POSITIVE_INFINITY; + return timeline.getSegmentAvailabilityDuration() != null; };