Class: shaka.media.PresentationTimeline

Constructor

new PresentationTimeline(presentationStartTimenullable, presentationDelay, autoCorrectDriftopt)

Parameters:
Name Type Attributes Default Description
presentationStartTime number <nullable>
The wall-clock time, in seconds, when the presentation started or will start. Only required for live.
presentationDelay number The delay to give the presentation, in seconds. Only required for live.
autoCorrectDrift boolean <optional>
true Whether to account for drift when determining the availability window.
Source:
See:

Members

autoCorrectDrift_ :boolean

Type:
  • boolean
Source:

availabilityTimeOffset_ :number

For low latency Dash, availabilityTimeOffset indicates a segment is available for download earlier than its availability start time. This field is the minimum availabilityTimeOffset value among the segments. We reduce the distance from live edge by this value.
Type:
  • number
Source:

clockOffset_ :number

Type:
  • number
Source:

duration_ :number

Type:
  • number
Source:

initialProgramDateTime_ :number

Type:
  • number
Source:

isLive2VodTransition_ :boolean

Type:
  • boolean
Source:

maxSegmentDuration_ :number

The maximum segment duration (in seconds). Can be based on explicitly- known segments or on signalling in the manifest.
Type:
  • number
Source:

maxSegmentEndTime_ :number

The maximum segment end time (in seconds, in the presentation timeline) for segments we explicitly know about. This is null if we have no explicit descriptions of segments, such as in DASH when using SegmentTemplate w/ duration. When this is non-null, the presentation start time is calculated from the segment end times.
Type:
  • number
Source:

minSegmentStartTime_ :number

The minimum segment start time (in seconds, in the presentation timeline) for segments we explicitly know about. This is null if we have no explicit descriptions of segments, such as in DASH when using SegmentTemplate w/ duration.
Type:
  • number
Source:

presentationDelay_ :number

Type:
  • number
Source:

presentationStartTime_ :number

Type:
  • number
Source:

segmentAvailabilityDuration_ :number

Type:
  • number
Source:

startTimeLocked_ :boolean

Type:
  • boolean
Source:

static_ :boolean

Type:
  • boolean
Source:

userSeekStart_ :number

Type:
  • number
Source:

Methods

assertIsValid()

Debug only: assert that the timeline parameters make sense for the type of presentation (VOD, IPR, live).
Source:

getAvailabilityTimeOffset() → {number}

Gets the presentation's segment availability time offset. This should be only configured for Low Latency Dash.
Source:
Returns:
availabilityTimeOffset parameter
Type
number

getDelay() → {number}

Gets the presentation delay in seconds.
Source:
Returns:
Type
number

getDuration() → {number}

Source:
Returns:
The presentation's duration in seconds. Infinity indicates that the presentation continues indefinitely.
Type
number

getInitialProgramDateTime() → {number}

Source:
Returns:
The initial program date time in seconds.
Type
number

getLiveEdge_() → {number}

Source:
Returns:
The current presentation time in seconds.
Type
number

getMaxSegmentDuration() → {number}

Source:
Returns:
The presentation's max segment duration in seconds.
Type
number

getMaxSegmentEndTime() → {number}

Gets the end time of the last available segment.
Source:
Returns:
Type
number

getPresentationStartTime() → {number}

Source:
Returns:
The presentation's start time in seconds.
Type
number

getSafeSeekRangeStart(offset) → {number}

Gets the seek range start time, offset by the given amount. This is used to ensure that we don't "fall" back out of the seek window while we are buffering.
Parameters:
Name Type Description
offset number The offset to add to the start time for live streams.
Source:
Returns:
The current seek start time, in seconds, relative to the start of the presentation.
Type
number

getSeekRangeEnd() → {number}

Gets the seek range end.
Source:
Returns:
Type
number

getSeekRangeStart() → {number}

Gets the seek range start time.
Source:
Returns:
Type
number

getSegmentAvailabilityDuration() → {number}

Gets the presentation's segment availability duration.
Source:
Returns:
Type
number

getSegmentAvailabilityEnd() → {number}

Gets the presentation's current segment availability end time. Segments starting after this time should be assumed to be unavailable.
Source:
Returns:
The current segment availability end time, in seconds, relative to the start of the presentation. For VOD, the availability end time is the content's duration. If the Player's playRangeEnd configuration is used, this can override the duration.
Type
number

getSegmentAvailabilityStart() → {number}

Gets the presentation's current segment availability start time. Segments ending at or before this time should be assumed to be unavailable.
Source:
Returns:
The current segment availability start time, in seconds, relative to the start of the presentation.
Type
number

isInProgress() → {boolean}

Source:
Returns:
True if the presentation is in progress (meaning not live, but also not completely available); otherwise, return false.
Type
boolean

isLive() → {boolean}

Source:
Returns:
True if the presentation is live; otherwise, return false.
Type
boolean

isStartTimeLocked() → {boolean}

Returns if the presentation timeline's start time is locked.
Source:
Returns:
Type
boolean

lockStartTime()

Lock the presentation timeline's start time. After this is called, no further adjustments to presentationStartTime_ will be permitted. This should be called after all Periods have been parsed, and all calls to notifySegments() from the initial manifest parse have been made. Without this, we can get assertion failures in SegmentIndex for certain DAI content. If DAI adds ad segments to the manifest faster than real-time, adjustments to presentationStartTime_ can cause availability windows to jump around on updates.
Source:

notifyMaxSegmentDuration(maxSegmentDuration)

Gives PresentationTimeline a Stream's maximum segment duration so it can size and position the segment availability window. This function should be called once for each Stream (no more, no less), but does not have to be called if notifySegments() is called instead for a particular stream.
Parameters:
Name Type Description
maxSegmentDuration number The maximum segment duration for a particular stream.
Source:

notifyMinSegmentStartTime(startTime)

Gives PresentationTimeline a Stream's minimum segment start time.
Parameters:
Name Type Description
startTime number
Source:

notifyPeriodDuration(startTime, endTime)

Gives PresentationTimeline an startTime and endTime of the period. This should be only set for Dash.
Parameters:
Name Type Description
startTime number
endTime number
Source:

notifySegments(referencesnon-null)

Gives PresentationTimeline an array of segments so it can size and position the segment availability window, and account for missing segment information. These segments do not necessarily need to all be from the same stream.
Parameters:
Name Type Description
references Array.<!shaka.media.SegmentReference>
Source:

notifyTimeRange(timelinenon-null, startOffset)

Gives PresentationTimeline a Stream's timeline so it can size and position the segment availability window, and account for missing segment information.
Parameters:
Name Type Description
timeline Array.<shaka.media.PresentationTimeline.TimeRange>
startOffset number
Source:

offset(offset)

Offsets the segment times by the given amount.
Parameters:
Name Type Description
offset number The number of seconds to offset by. A positive number adjusts the segment times forward.
Source:

setAvailabilityTimeOffset(offset)

Sets the presentation's segment availability time offset. This should be only set for Low Latency Dash. The segments are available earlier for download than the availability start time, so we can move closer to the live edge.
Parameters:
Name Type Description
offset number
Source:

setClockOffset(offset)

Sets the clock offset, which is the difference between the client's clock and the server's clock, in milliseconds (i.e., serverTime = Date.now() + clockOffset).
Parameters:
Name Type Description
offset number The clock offset, in ms.
Source:

setDelay(delay)

Sets the presentation delay in seconds.
Parameters:
Name Type Description
delay number
Source:

setDuration(duration)

Sets the presentation's duration.
Parameters:
Name Type Description
duration number The presentation's duration in seconds. Infinity indicates that the presentation continues indefinitely.
Source:

setInitialProgramDateTime(initialProgramDateTime)

Sets the initial program date time.
Parameters:
Name Type Description
initialProgramDateTime number
Source:

setPresentationStartTime(presentationStartTime)

Sets the presentation's start time.
Parameters:
Name Type Description
presentationStartTime number The wall-clock time, in seconds, when the presentation started or will start. Only required for live.
Source:

setSegmentAvailabilityDuration(segmentAvailabilityDuration)

Sets the presentation's segment availability duration. The segment availability duration should only be set for live.
Parameters:
Name Type Description
segmentAvailabilityDuration number The presentation's new segment availability duration in seconds.
Source:

setStatic(isStatic)

Sets the presentation's static flag.
Parameters:
Name Type Description
isStatic boolean If true, the presentation is static, meaning all segments are available at once.
Source:

setUserSeekStart(time)

Sets the start time of the user-defined seek range. This is only used for VOD content.
Parameters:
Name Type Description
time number
Source:

usingPresentationStartTime() → {boolean}

True if the presentation start time is being used to calculate the live edge. Using the presentation start time means that the stream may be subject to encoder drift. At runtime, we will avoid using the presentation start time whenever possible.
Source:
Returns:
Type
boolean

Type Definitions

TimeRange

Defines a time range of a media segment. Times are in seconds.
Type:
  • {start: number, unscaledStart: number, end: number, partialSegments: number, segmentPosition: number}
Properties:
Name Type Description
start number The start time of the range.
unscaledStart number The start time of the range in representation timescale units.
end number The end time (exclusive) of the range.
partialSegments number The number of partial segments
segmentPosition number The segment position of the timeline entry as it appears in the manifest
Source: