mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
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:
@@ -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
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user