public abstract class Timeline
extends java.lang.Object
Timeline instances are immutable. For cases where the available media is changing dynamically (e.g. live streams) a timeline provides a snapshot of the media currently available.
A timeline consists of related Timeline.Periods and Timeline.Windows. A period defines a single
logical piece of media, for example a media file. A window spans one or more periods, defining
the region within those periods that's currently available for playback along with additional
information such as whether seeking is supported within the window. Each window defines a default
position, which is the position from which playback will start when the player starts playing the
window. The following examples illustrate timelines for various use cases.
Timeline.Window.isDynamic set to true if
the stream is still live. Its default position is typically near to the live edge (indicated by
the black dot in the figure above).
| Modifier and Type | Class and Description |
|---|---|
static class |
Timeline.Period
Holds information about a period in a
Timeline. |
static class |
Timeline.Window
Holds information about a window in a
Timeline. |
| Modifier and Type | Field and Description |
|---|---|
static Timeline |
EMPTY
An empty timeline.
|
| Constructor and Description |
|---|
Timeline() |
| Modifier and Type | Method and Description |
|---|---|
abstract int |
getIndexOfPeriod(java.lang.Object uid)
Returns the index of the period identified by its unique
id, or C.INDEX_UNSET
if the period is not in the timeline. |
Timeline.Period |
getPeriod(int periodIndex,
Timeline.Period period)
Populates a
Timeline.Period with data for the period at the specified index. |
abstract Timeline.Period |
getPeriod(int periodIndex,
Timeline.Period period,
boolean setIds)
Populates a
Timeline.Period with data for the period at the specified index. |
abstract int |
getPeriodCount()
Returns the number of periods in the timeline.
|
Timeline.Window |
getWindow(int windowIndex,
Timeline.Window window)
Populates a
Timeline.Window with data for the window at the specified index. |
Timeline.Window |
getWindow(int windowIndex,
Timeline.Window window,
boolean setIds)
Populates a
Timeline.Window with data for the window at the specified index. |
abstract Timeline.Window |
getWindow(int windowIndex,
Timeline.Window window,
boolean setIds,
long defaultPositionProjectionUs)
Populates a
Timeline.Window with data for the window at the specified index. |
abstract int |
getWindowCount()
Returns the number of windows in the timeline.
|
boolean |
isEmpty()
Returns whether the timeline is empty.
|
public static final Timeline EMPTY
public final boolean isEmpty()
public abstract int getWindowCount()
public final Timeline.Window getWindow(int windowIndex, Timeline.Window window)
Timeline.Window with data for the window at the specified index. Does not populate
Timeline.Window.id.windowIndex - The index of the window.window - The Timeline.Window to populate. Must not be null.Timeline.Window, for convenience.public Timeline.Window getWindow(int windowIndex, Timeline.Window window, boolean setIds)
Timeline.Window with data for the window at the specified index.windowIndex - The index of the window.window - The Timeline.Window to populate. Must not be null.setIds - Whether Timeline.Window.id should be populated. If false, the field will be set to
null. The caller should pass false for efficiency reasons unless the field is required.Timeline.Window, for convenience.public abstract Timeline.Window getWindow(int windowIndex, Timeline.Window window, boolean setIds, long defaultPositionProjectionUs)
Timeline.Window with data for the window at the specified index.windowIndex - The index of the window.window - The Timeline.Window to populate. Must not be null.setIds - Whether Timeline.Window.id should be populated. If false, the field will be set to
null. The caller should pass false for efficiency reasons unless the field is required.defaultPositionProjectionUs - A duration into the future that the populated window's
default start position should be projected.Timeline.Window, for convenience.public abstract int getPeriodCount()
public final Timeline.Period getPeriod(int periodIndex, Timeline.Period period)
Timeline.Period with data for the period at the specified index. Does not populate
Timeline.Period.id and Timeline.Period.uid.periodIndex - The index of the period.period - The Timeline.Period to populate. Must not be null.Timeline.Period, for convenience.public abstract Timeline.Period getPeriod(int periodIndex, Timeline.Period period, boolean setIds)
Timeline.Period with data for the period at the specified index.periodIndex - The index of the period.period - The Timeline.Period to populate. Must not be null.setIds - Whether Timeline.Period.id and Timeline.Period.uid should be populated. If false,
the fields will be set to null. The caller should pass false for efficiency reasons unless
the fields are required.Timeline.Period, for convenience.public abstract int getIndexOfPeriod(java.lang.Object uid)
id, or C.INDEX_UNSET
if the period is not in the timeline.uid - A unique identifier for a period.C.INDEX_UNSET if the period was not found.