Class: shaka.media.SegmentIndex

Constructor

new SegmentIndex(referencesnon-null)

Creates a SegmentIndex.
Parameters:
Name Type Description
references Array.<!shaka.media.SegmentReference> The list of SegmentReferences, which must be sorted first by their start times (ascending) and second by their end times (ascending), and have continuous, increasing positions.
Implements:
Source:

Members

(private) references_ :Array.<!shaka.media.SegmentReference>

Type:
Source:

Methods

(private, static) assertCorrectReferences_(referencesnon-null)

Asserts that the given SegmentReferences are sorted and have continuous, increasing positions.
Parameters:
Name Type Description
references Array.<shaka.media.SegmentReference>
Source:

destroy() → (non-null) {Promise}

Destroys the object, releasing all resources and shutting down all operations. Returns a Promise which is resolved when destruction is complete. This Promise should never be rejected.
Implements:
Source:
Returns:
Type
Promise

evict(time)

Removes all SegmentReferences that end before the given time.
Parameters:
Name Type Description
time number The time in seconds.
Source:

find(time) → (nullable) {number}

Finds the position of the segment for the given time, in seconds, relative to the start of a particular Period. Returns the position of the segment with the largest end time if more than one segment is known for the given time.
Parameters:
Name Type Description
time number
Source:
Returns:
The position of the segment, or null if the position of the segment could not be determined.
Type
number

fit(periodDurationnullable)

Expands the first SegmentReference so it begins at the start of its Period if it already begins close to the start of its Period. Also expands or contracts the last SegmentReference so it ends at the end of its Period. Do not call on the last period of a live presentation (unknown duration). It is okay to call on the other periods of a live presentation, where the duration is known and another period has been added.
Parameters:
Name Type Attributes Description
periodDuration number <nullable>
Source:

get(position) → {shaka.media.SegmentReference}

Gets the SegmentReference for the segment at the given position.
Parameters:
Name Type Description
position number The position of the segment.
Source:
Returns:
The SegmentReference, or null if no such SegmentReference exists.
Type
shaka.media.SegmentReference

merge(referencesnon-null)

Merges the given SegmentReferences. Supports extending the original references only. Will not replace old references or interleave new ones.
Parameters:
Name Type Description
references Array.<!shaka.media.SegmentReference> The list of SegmentReferences, which must be sorted first by their start times (ascending) and second by their end times (ascending), and have continuous, increasing positions.
Source: