Use consistent definition of "live".

If the content has a segment availability window then
treat it as live. This makes the definition of "live"
consistent between Playhead and Player.

Issue #340

Change-Id: I9a93ddae9e2615c2e2a745dff5f49c025fda61dc
This commit is contained in:
Timothy Drews
2016-04-19 15:50:16 -07:00
parent 59fb1362be
commit bc55004c8f
2 changed files with 12 additions and 7 deletions
+9 -6
View File
@@ -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;
+3 -1
View File
@@ -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;
};