docs/doc/reference/com/google/android/exoplayer2/testutil/FakeTimeline.html
Package com.google.android.exoplayer2.testutil
All Implemented Interfaces:Bundleable
public final classFakeTimelineextends[Timeline](../Timeline.html "class in com.google.android.exoplayer2")
Fake Timeline which can be setup to return custom FakeTimeline.TimelineWindowDefinitions.
Nested Classes | Modifier and Type | Class | Description |
| --- | --- | --- |
| static class | FakeTimeline.TimelineWindowDefinition |
Definition used to define a FakeTimeline.
|
-
Timeline.Period, Timeline.RemotableTimeline, Timeline.Window
-
Bundleable.Creator<T extends Bundleable>
Fields | Modifier and Type | Field | Description |
| --- | --- | --- |
| static MediaItem | FAKE_MEDIA_ITEM |
The fake media item used by the fake timeline.
|
-
CREATOR, EMPTY
Constructors | Constructor | Description |
| --- | --- |
| FakeTimeline() |
Create a fake timeline with one seekable, non-dynamic window with one period and a duration of FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US.
|
| FakeTimeline(int windowCount, Object... manifests) |
Creates a fake timeline with the given number of seekable, non-dynamic windows with one period with a duration of FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US each.
|
| FakeTimeline(FakeTimeline.TimelineWindowDefinition... windowDefinitions) |
Creates a fake timeline with the given window definitions.
|
| FakeTimeline(Object[] manifests, ShuffleOrder shuffleOrder, FakeTimeline.TimelineWindowDefinition... windowDefinitions) |
Creates a fake timeline with the given window definitions and ShuffleOrder.
|
| FakeTimeline(Object[] manifests, FakeTimeline.TimelineWindowDefinition... windowDefinitions) |
Creates a fake timeline with the given window definitions.
|
All Methods Static Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| static AdPlaybackState | createAdPlaybackState(int adsPerAdGroup, long... adGroupTimesUs) |
Returns an ad playback state with the specified number of ads in each of the specified ad groups, each ten seconds long.
|
| static FakeTimeline | createMultiPeriodAdTimeline(Object windowId, int numberOfPlayedAds, boolean... isAdPeriodFlags) |
Creates a multi-period timeline with ad and content periods specified by the flags passed as var-arg arguments.
|
| ImmutableMap<Object,AdPlaybackState> | getAdPlaybackStates(int windowIndex) |
Returns a map of ad playback states keyed by the period UID.
|
| int | getFirstWindowIndex(boolean shuffleModeEnabled) |
Returns the index of the first window in the playback order depending on whether shuffling is enabled.
|
| 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.
|
| int | getLastWindowIndex(boolean shuffleModeEnabled) |
Returns the index of the last window in the playback order depending on whether shuffling is enabled.
|
| int | getNextWindowIndex(int windowIndex, @com.google.android.exoplayer2.Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) |
Returns the index of the window after the window at index windowIndex depending on the repeatMode and whether shuffling is enabled.
|
| 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.
|
| int | getPreviousWindowIndex(int windowIndex, @com.google.android.exoplayer2.Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) |
Returns the index of the window before the window at index windowIndex depending on the repeatMode and whether shuffling is enabled.
|
| 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.
|
-
equals, getNextPeriodIndex, getPeriod, getPeriodByUid, getPeriodPosition, getPeriodPosition, getPeriodPositionUs, getPeriodPositionUs, getWindow, hashCode, isEmpty, isLastPeriod, toBundle, toBundleWithOneWindowOnly
-
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
public static final[MediaItem](../MediaItem.html "class in com.google.android.exoplayer2")FAKE_MEDIA_ITEM
The fake media item used by the fake timeline.
-
public FakeTimeline()
Create a fake timeline with one seekable, non-dynamic window with one period and a duration of FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US.
-
public FakeTimeline(int windowCount,[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")... manifests)
Creates a fake timeline with the given number of seekable, non-dynamic windows with one period with a duration of FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US each.
Parameters:windowCount - The number of windows.manifests - The manifests of the windows.
-
public FakeTimeline([FakeTimeline.TimelineWindowDefinition](FakeTimeline.TimelineWindowDefinition.html "class in com.google.android.exoplayer2.testutil")... windowDefinitions)
Creates a fake timeline with the given window definitions.
Parameters:windowDefinitions - A list of FakeTimeline.TimelineWindowDefinitions.
-
public FakeTimeline([Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")[] manifests,[FakeTimeline.TimelineWindowDefinition](FakeTimeline.TimelineWindowDefinition.html "class in com.google.android.exoplayer2.testutil")... windowDefinitions)
Creates a fake timeline with the given window definitions.
Parameters:manifests - The manifests of the windows.windowDefinitions - A list of FakeTimeline.TimelineWindowDefinitions.
-
public FakeTimeline([Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")[] manifests,[ShuffleOrder](../source/ShuffleOrder.html "interface in com.google.android.exoplayer2.source")shuffleOrder,[FakeTimeline.TimelineWindowDefinition](FakeTimeline.TimelineWindowDefinition.html "class in com.google.android.exoplayer2.testutil")... windowDefinitions)
Creates a fake timeline with the given window definitions and ShuffleOrder.
Parameters:manifests - The manifests of the windows.shuffleOrder - A shuffle ordering for the windows.windowDefinitions - A list of FakeTimeline.TimelineWindowDefinitions.
-
public static[AdPlaybackState](../source/ads/AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")createAdPlaybackState(int adsPerAdGroup,
long... adGroupTimesUs)
Returns an ad playback state with the specified number of ads in each of the specified ad groups, each ten seconds long.
Parameters:adsPerAdGroup - The number of ads per ad group.adGroupTimesUs - The times of ad groups, in microseconds.Returns:The ad playback state.
-
public static[FakeTimeline](FakeTimeline.html "class in com.google.android.exoplayer2.testutil")createMultiPeriodAdTimeline([Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")windowId,
int numberOfPlayedAds,
boolean... isAdPeriodFlags)
Creates a multi-period timeline with ad and content periods specified by the flags passed as var-arg arguments.
Period uid end up being a new Pair<>(windowId, periodIndex).
Parameters:windowId - The window ID.numberOfPlayedAds - The number of ads that should be marked as played.isAdPeriodFlags - A value of true indicates an ad period. A value of false indicated a content period.Returns:A timeline with a single window with as many periods as var-arg arguments.
-
public int getWindowCount()
Description copied from class: Timeline
Returns the number of windows in the timeline.
Specified by:getWindowCount in class Timeline
-
public int getNextWindowIndex(int windowIndex,[@RepeatMode](../Player.RepeatMode.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.Player.RepeatMode int repeatMode,
boolean shuffleModeEnabled)
Description copied from class: Timeline
Returns the index of the window after the window at index windowIndex depending on the repeatMode and whether shuffling is enabled.
Overrides:getNextWindowIndex in class TimelineParameters:windowIndex - Index of a window in the timeline.repeatMode - A repeat mode.shuffleModeEnabled - Whether shuffling is enabled.Returns:The index of the next window, or C.INDEX_UNSET if this is the last window.
-
public int getPreviousWindowIndex(int windowIndex,[@RepeatMode](../Player.RepeatMode.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.Player.RepeatMode int repeatMode,
boolean shuffleModeEnabled)
Description copied from class: Timeline
Returns the index of the window before the window at index windowIndex depending on the repeatMode and whether shuffling is enabled.
Overrides:getPreviousWindowIndex in class TimelineParameters:windowIndex - Index of a window in the timeline.repeatMode - A repeat mode.shuffleModeEnabled - Whether shuffling is enabled.Returns:The index of the previous window, or C.INDEX_UNSET if this is the first window.
-
public int getLastWindowIndex(boolean shuffleModeEnabled)
Description copied from class: Timeline
Returns the index of the last window in the playback order depending on whether shuffling is enabled.
Overrides:getLastWindowIndex in class TimelineParameters:shuffleModeEnabled - Whether shuffling is enabled.Returns:The index of the last window in the playback order, or C.INDEX_UNSET if the timeline is empty.
-
public int getFirstWindowIndex(boolean shuffleModeEnabled)
Description copied from class: Timeline
Returns the index of the first window in the playback order depending on whether shuffling is enabled.
Overrides:getFirstWindowIndex in class TimelineParameters:shuffleModeEnabled - Whether shuffling is enabled.Returns:The index of the first window in the playback order, or C.INDEX_UNSET if the timeline is empty.
-
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.
-
public[ImmutableMap](https://guava.dev/releases/31.1-android/api/docs/com/google/common/collect/ImmutableMap.html?is-external=true "class or interface in com.google.common.collect")<[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang"),[AdPlaybackState](../source/ads/AdPlaybackState.html "class in com.google.android.exoplayer2.source.ads")> getAdPlaybackStates(int windowIndex)
Returns a map of ad playback states keyed by the period UID.
Parameters:windowIndex - The window index of the window to get the map of ad playback states from.Returns:The map of ad playback states.