docs/doc/reference/com/google/android/exoplayer2/testutil/FakeMultiPeriodLiveTimeline.html
Package com.google.android.exoplayer2.testutil
All Implemented Interfaces:Bundleable
public classFakeMultiPeriodLiveTimelineextends[Timeline](../Timeline.html "class in com.google.android.exoplayer2")
A fake Timeline that produces a live window with periods according to the available time range.
The parameters passed to the constructor define the availability start time, the window size and now. Use advanceNowUs(long) to advance the live window of the timeline accordingly.
The first available period with ID 0 (zero) starts at availabilityStartTimeUs. The live window starts at now - liveWindowDurationUs with the first period of the window having its ID relative to the first available period.
Periods are either of type content or ad as defined by the ad sequence pattern. A period is an ad if adSequencePattern[id % adSequencePattern.length] evaluates to true. Ad periods have a duration of AD_PERIOD_DURATION_MS and content periods have a duration of PERIOD_DURATION_MS.
-
Timeline.Period, Timeline.RemotableTimeline, Timeline.Window
-
Bundleable.Creator<T extends Bundleable>
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static long | AD_PERIOD_DURATION_MS | |
| static long | PERIOD_DURATION_MS | |
-
CREATOR, EMPTY
Constructors | Constructor | Description |
| --- | --- |
| FakeMultiPeriodLiveTimeline(long availabilityStartTimeMs, long liveWindowDurationUs, long nowUs, boolean[] adSequencePattern, long[] periodDurationMsPattern, boolean isContentTimeline, boolean populateAds, boolean playedAds) |
Creates an instance.
|
All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | advanceNowUs(long durationUs) |
Advances the live window by the given duration, in microseconds.
|
| int | getIndexOfPeriod(Object uid) |
Returns the index of the period identified by its unique Timeline.Period.uid, or C.INDEX_UNSET if the period is not in the timeline.
|
| Timeline.Period | getPeriod(int periodIndex, Timeline.Period period, boolean setIds) |
Populates a Timeline.Period with data for the period at the specified index.
|
| int | getPeriodCount() |
Returns the number of periods in the timeline.
|
| long | getPeriodStartTimeUs(int periodIndex) |
Returns the period start time since Unix epoch, in microseconds.
|
| Object | getUidOfPeriod(int periodIndex) |
Returns the unique id of the period identified by its index in the timeline.
|
| Timeline.Window | getWindow(int windowIndex, Timeline.Window window, long defaultPositionProjectionUs) |
Populates a Timeline.Window with data for the window at the specified index.
|
| int | getWindowCount() |
Returns the number of windows in the timeline.
|
| long | getWindowStartTimeUs() |
The window's start time in microseconds since the Unix epoch, or C.TIME_UNSET if unknown or not applicable.
|
-
equals, getFirstWindowIndex, getLastWindowIndex, getNextPeriodIndex, getNextWindowIndex, getPeriod, getPeriodByUid, getPeriodPosition, getPeriodPosition, getPeriodPositionUs, getPeriodPositionUs, getPreviousWindowIndex, getWindow, hashCode, isEmpty, isLastPeriod, toBundle, toBundleWithOneWindowOnly
-
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
public static final long AD_PERIOD_DURATION_MS
See Also:Constant Field Values
-
public static final long PERIOD_DURATION_MS
See Also:Constant Field Values
-
public FakeMultiPeriodLiveTimeline(long availabilityStartTimeMs,
long liveWindowDurationUs,
long nowUs,
boolean[] adSequencePattern,
long[] periodDurationMsPattern,
boolean isContentTimeline,
boolean populateAds,
boolean playedAds)
Creates an instance.
Parameters:availabilityStartTimeMs - The start time of the available time range, UNIX epoch in milliseconds.liveWindowDurationUs - The duration of the live window.nowUs - The current time that determines the end of the live window.adSequencePattern - The repeating pattern of periods starting at availabilityStartTimeMs. True is an ad period, and false a content period.periodDurationMsPattern - The repeating pattern of periods durations starting at availabilityStartTimeMs, in milliseconds. Must have the same length as adSequencePattern.isContentTimeline - Whether the timeline is a content timeline without AdPlaybackStates.populateAds - Whether to populate ads in the same way if an ad event has been received.playedAds - Whether ads should be marked as played if populated.
-
public void advanceNowUs(long durationUs)
Advances the live window by the given duration, in microseconds.
-
public long getWindowStartTimeUs()
The window's start time in microseconds since the Unix epoch, or C.TIME_UNSET if unknown or not applicable.
-
public long getPeriodStartTimeUs(int periodIndex)
Returns the period start time since Unix epoch, in microseconds.
Note: The returned value has millisecond precision only, so the trailing 3 digits are always zeros.
-
public int getWindowCount()
Description copied from class: Timeline
Returns the number of windows in the timeline.
Specified by:getWindowCount in class Timeline
-
public[Timeline.Window](../Timeline.Window.html "class in com.google.android.exoplayer2")getWindow(int windowIndex,[Timeline.Window](../Timeline.Window.html "class in com.google.android.exoplayer2")window,
long defaultPositionProjectionUs)
Description copied from class: Timeline
Populates a Timeline.Window with data for the window at the specified index.
Specified by:getWindow in class TimelineParameters:windowIndex - The index of the window.window - The Timeline.Window to populate. Must not be null.defaultPositionProjectionUs - A duration into the future that the populated window's default start position should be projected.Returns:The populated Timeline.Window, for convenience.
-
public int getPeriodCount()
Description copied from class: Timeline
Returns the number of periods in the timeline.
Specified by:getPeriodCount in class Timeline
-
public[Timeline.Period](../Timeline.Period.html "class in com.google.android.exoplayer2")getPeriod(int periodIndex,[Timeline.Period](../Timeline.Period.html "class in com.google.android.exoplayer2")period,
boolean setIds)
Description copied from class: Timeline
Populates a Timeline.Period with data for the period at the specified index.
Specified by:getPeriod in class TimelineParameters: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.Returns:The populated Timeline.Period, for convenience.
-
public int getIndexOfPeriod([Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")uid)
Description copied from class: Timeline
Returns the index of the period identified by its unique Timeline.Period.uid, or C.INDEX_UNSET if the period is not in the timeline.
Specified by:getIndexOfPeriod in class TimelineParameters:uid - A unique identifier for a period.Returns:The index of the period, or C.INDEX_UNSET if the period was not found.
-
public[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")getUidOfPeriod(int periodIndex)
Description copied from class: Timeline
Returns the unique id of the period identified by its index in the timeline.
Specified by:getUidOfPeriod in class TimelineParameters:periodIndex - The index of the period.Returns:The unique id of the period.