# FakeMediaSource.InitialTimeline

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/FakeMediaSource.java+class:androidx.media3.test.utils.FakeMediaSource.InitialTimeline)

*** ** * ** ***


```
public class FakeMediaSource.InitialTimeline extends ForwardingTimeline
```

<br />

|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||||
| ↳ | [androidx.media3.common.Timeline](https://developer.android.com/reference/androidx/media3/common/Timeline) |||
|   | ↳ | [androidx.media3.exoplayer.source.ForwardingTimeline](https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline) ||
|   |   | ↳ | [androidx.media3.test.utils.FakeMediaSource.InitialTimeline](https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.InitialTimeline) |

*** ** * ** ***

A forwarding timeline to provide an initial timeline for fake multi window sources.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.InitialTimeline#InitialTimeline(androidx.media3.common.Timeline)(https://developer.android.com/reference/androidx/media3/common/Timeline timeline)` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeMediaSource.InitialTimeline#getWindow(int,androidx.media3.common.Timeline.Window,long)( int windowIndex, https://developer.android.com/reference/androidx/media3/common/Timeline.Window window, long defaultPositionProjectionUs )` Populates a `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` with data for the window at the specified index. |

### Inherited Constants

From [androidx.media3.common.Timeline](https://developer.android.com/reference/androidx/media3/common/Timeline) `static final https://developer.android.com/reference/androidx/media3/common/Timeline` `https://developer.android.com/reference/androidx/media3/common/Timeline#EMPTY()`

An empty timeline.

### Inherited fields

From [androidx.media3.exoplayer.source.ForwardingTimeline](https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline) `final https://developer.android.com/reference/androidx/media3/common/Timeline` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#timeline()`

### Inherited methods

From [androidx.media3.exoplayer.source.ForwardingTimeline](https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline) `final boolean` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` `int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getFirstWindowIndex(boolean)(boolean shuffleModeEnabled)`

Returns the index of the first window in the playback order depending on whether shuffling is enabled.
`int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getIndexOfPeriod(java.lang.Object)(https://developer.android.com/reference/java/lang/Object.html uid)`

Returns the index of the period identified by its unique `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#uid()`, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if the period is not in the timeline.
`int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getLastWindowIndex(boolean)(boolean shuffleModeEnabled)`

Returns the index of the last window in the playback order depending on whether shuffling is enabled.
`int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getNextWindowIndex(int,int,boolean)(
int windowIndex,
@https://developer.android.com/reference/androidx/media3/common/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.
`https://developer.android.com/reference/androidx/media3/common/Timeline.Period` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getPeriod(int,androidx.media3.common.Timeline.Period,boolean)(int periodIndex, https://developer.android.com/reference/androidx/media3/common/Timeline.Period period, boolean setIds)`

Populates a `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` with data for the period at the specified index.
`final https://developer.android.com/reference/androidx/media3/common/Timeline.Period` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getPeriodByUid(java.lang.Object,androidx.media3.common.Timeline.Period)(https://developer.android.com/reference/java/lang/Object.html periodUid, https://developer.android.com/reference/androidx/media3/common/Timeline.Period period)`

Populates a `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` with data for the period with the specified unique identifier.
`int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getPeriodCount()()`

Returns the number of periods in the timeline.
`int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getPreviousWindowIndex(int,int,boolean)(
int windowIndex,
@https://developer.android.com/reference/androidx/media3/common/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.
`https://developer.android.com/reference/java/lang/Object.html` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getUidOfPeriod(int)(int periodIndex)`

Returns the unique id of the period identified by its index in the timeline.
`int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#getWindowCount()()`

Returns the number of windows in the timeline.
`final int` `https://developer.android.com/reference/androidx/media3/exoplayer/source/ForwardingTimeline#hashCode()()` From [androidx.media3.common.Timeline](https://developer.android.com/reference/androidx/media3/common/Timeline) `final https://developer.android.com/reference/androidx/media3/common/Timeline` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/common/Timeline#copyWithSingleWindow(int)(int windowIndex)`

Returns a copy of this timeline containing just the single specified `https://developer.android.com/reference/androidx/media3/common/Timeline.Window`.
`static https://developer.android.com/reference/androidx/media3/common/Timeline` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
[fromBundle](https://developer.android.com/reference/androidx/media3/common/Timeline#fromBundle(android.os.Bundle))(https://developer.android.com/reference/android/os/Bundle.html bundle)`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Timeline#fromBundle(android.os.Bundle,int)` instead.

<br />

`static https://developer.android.com/reference/androidx/media3/common/Timeline` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/common/Timeline#fromBundle(android.os.Bundle,int)(https://developer.android.com/reference/android/os/Bundle.html bundle, int interfaceVersion)`

Restores a `Timeline` from a `https://developer.android.com/reference/android/os/Bundle.html`.
`final int` `https://developer.android.com/reference/androidx/media3/common/Timeline#getNextPeriodIndex(int,androidx.media3.common.Timeline.Period,androidx.media3.common.Timeline.Window,int,boolean)(
int periodIndex,
https://developer.android.com/reference/androidx/media3/common/Timeline.Period period,
https://developer.android.com/reference/androidx/media3/common/Timeline.Window window,
@https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode,
boolean shuffleModeEnabled
)`

Returns the index of the period after the period at index `periodIndex` depending on the `repeatMode` and whether shuffling is enabled.
`final https://developer.android.com/reference/androidx/media3/common/Timeline.Period` `https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriod(int,androidx.media3.common.Timeline.Period)(int periodIndex, https://developer.android.com/reference/androidx/media3/common/Timeline.Period period)`

Populates a `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` with data for the period at the specified index.
`final https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Object.html, https://developer.android.com/reference/java/lang/Long.html>` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "this.getPeriodPositionUs(window, period, windowIndex, windowPositionUs)")
[getPeriodPosition](https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriodPosition(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long))(
https://developer.android.com/reference/androidx/media3/common/Timeline.Window window,
https://developer.android.com/reference/androidx/media3/common/Timeline.Period period,
int windowIndex,
long windowPositionUs
)`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)` instead.

<br />

`final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Object.html, https://developer.android.com/reference/java/lang/Long.html>` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "this.getPeriodPositionUs("
+ "window, period, windowIndex, windowPositionUs, defaultPositionProjectionUs)")
[getPeriodPosition](https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriodPosition(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long))(
https://developer.android.com/reference/androidx/media3/common/Timeline.Window window,
https://developer.android.com/reference/androidx/media3/common/Timeline.Period period,
int windowIndex,
long windowPositionUs,
long defaultPositionProjectionUs
)`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long)` instead.

<br />

`final https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Object.html, https://developer.android.com/reference/java/lang/Long.html>` `https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)(
https://developer.android.com/reference/androidx/media3/common/Timeline.Window window,
https://developer.android.com/reference/androidx/media3/common/Timeline.Period period,
int windowIndex,
long windowPositionUs
)`

Calls `https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)` with a zero default position projection.
`final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/util/Pair.html<https://developer.android.com/reference/java/lang/Object.html, https://developer.android.com/reference/java/lang/Long.html>` `https://developer.android.com/reference/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long)(
https://developer.android.com/reference/androidx/media3/common/Timeline.Window window,
https://developer.android.com/reference/androidx/media3/common/Timeline.Period period,
int windowIndex,
long windowPositionUs,
long defaultPositionProjectionUs
)`

Converts `(windowIndex, windowPositionUs)` to the corresponding `(periodUid,
periodPositionUs)`.
`final https://developer.android.com/reference/androidx/media3/common/Timeline.Window` `https://developer.android.com/reference/androidx/media3/common/Timeline#getWindow(int,androidx.media3.common.Timeline.Window)(int windowIndex, https://developer.android.com/reference/androidx/media3/common/Timeline.Window window)`

Populates a `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` with data for the window at the specified index.
`abstract https://developer.android.com/reference/androidx/media3/common/Timeline.Window` `https://developer.android.com/reference/androidx/media3/common/Timeline#getWindow(int,androidx.media3.common.Timeline.Window,long)(
int windowIndex,
https://developer.android.com/reference/androidx/media3/common/Timeline.Window window,
long defaultPositionProjectionUs
)`

Populates a `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` with data for the window at the specified index.
`final boolean` `https://developer.android.com/reference/androidx/media3/common/Timeline#isEmpty()()`

Returns whether the timeline is empty.
`final boolean` `https://developer.android.com/reference/androidx/media3/common/Timeline#isLastPeriod(int,androidx.media3.common.Timeline.Period,androidx.media3.common.Timeline.Window,int,boolean)(
int periodIndex,
https://developer.android.com/reference/androidx/media3/common/Timeline.Period period,
https://developer.android.com/reference/androidx/media3/common/Timeline.Window window,
@https://developer.android.com/reference/androidx/media3/common/Player.RepeatMode int repeatMode,
boolean shuffleModeEnabled
)`

Returns whether the given period is the last period of the timeline depending on the `
repeatMode` and whether shuffling is enabled.
`final https://developer.android.com/reference/android/os/Bundle.html` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
[toBundle](https://developer.android.com/reference/androidx/media3/common/Timeline#toBundle())()`

**This method is deprecated.**

Use `https://developer.android.com/reference/androidx/media3/common/Timeline#toBundle(int)` instead.

<br />

`final https://developer.android.com/reference/android/os/Bundle.html` `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi
https://developer.android.com/reference/androidx/media3/common/Timeline#toBundle(int)(int interfaceVersion)`

Returns a `https://developer.android.com/reference/android/os/Bundle.html` representing the information stored in this object.

## Public constructors

### InitialTimeline

```
public InitialTimeline(Timeline timeline)
```

## Public methods

### getWindow

```
public Timeline.Window getWindow(
    int windowIndex,
    Timeline.Window window,
    long defaultPositionProjectionUs
)
```

Populates a `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` with data for the window at the specified index.

| Parameters |
|---|---|
| `int windowIndex` | The index of the window. |
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Window window` | The `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` to populate. Must not be null. |
| `long defaultPositionProjectionUs` | A duration into the future that the populated window's default start position should be projected. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` | The populated `https://developer.android.com/reference/androidx/media3/common/Timeline.Window`, for convenience. |