# Timeline

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

*** ** * ** ***


```
abstract class Timeline
```

<br />

Known direct subclasses [AbstractConcatenatedTimeline](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/AbstractConcatenatedTimeline), [FakeMultiPeriodLiveTimeline](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeMultiPeriodLiveTimeline), [FakeTimeline](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTimeline), [ForwardingTimeline](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ForwardingTimeline), [MaskingMediaSource.PlaceholderTimeline](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MaskingMediaSource.PlaceholderTimeline), [SinglePeriodTimeline](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SinglePeriodTimeline), [Timeline.RemotableTimeline](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.RemotableTimeline)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/AbstractConcatenatedTimeline` | Abstract base class for the concatenation of one or more `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`s. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeMultiPeriodLiveTimeline` | A fake `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` that produces a live window with periods according to the available time range. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTimeline` | Fake `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` which can be setup to return custom `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTimeline.TimelineWindowDefinition`s. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ForwardingTimeline` | An overridable `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` implementation forwarding methods to another timeline. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/MaskingMediaSource.PlaceholderTimeline` | A timeline with one dynamic window with a period of indeterminate duration. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/SinglePeriodTimeline` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` consisting of a single period and static window. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.RemotableTimeline` | A concrete class of `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` to restore a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` instance from a `https://developer.android.com/reference/android/os/Bundle.html` sent by another process via `https://developer.android.com/reference/android/os/IBinder.html`. |

Known indirect subclasses [AdTimeline](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ads/AdTimeline), [FakeMediaSource.InitialTimeline](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeMediaSource.InitialTimeline), [TimelineWithUpdatedMediaItem](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TimelineWithUpdatedMediaItem)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/ads/AdTimeline` | A custom `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` for sources that have `https://developer.android.com/reference/kotlin/androidx/media3/common/AdPlaybackState` split among multiple periods. |
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeMediaSource.InitialTimeline` | A forwarding timeline to provide an initial timeline for fake multi window sources. |
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/TimelineWithUpdatedMediaItem` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` that overrides the `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem`. |

*** ** * ** ***

A flexible representation of the structure of media. A timeline is able to represent the structure of a wide variety of media, from simple cases like a single media file through to complex compositions of media such as playlists and streams with inserted ads. Instances are immutable. For cases where media is changing dynamically (e.g. live streams), a timeline provides a snapshot of the current state.

A timeline consists of `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period`.

- A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` usually corresponds to one playlist item. It may span one or more periods and it defines the region within those periods that's currently available for playback. The window also provides additional information such as whether seeking is supported within the window and the default position, which is the position from which playback will start when the player starts playing the window.
- A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` defines a single logical piece of media, for example a media file. It may also define groups of ads inserted into the media, along with information about whether those ads have been loaded and played.

The following examples illustrate timelines for various use cases.

## Single media file or on-demand stream

![Example timeline for a single file](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-single-file.svg)

A timeline for a single media file or on-demand stream consists of a single period and window. The window spans the whole period, indicating that all parts of the media are available for playback. The window's default position is typically at the start of the period (indicated by the black dot in the figure above).

## Playlist of media files or on-demand streams

![Example timeline for a playlist of files](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-playlist.svg)

A timeline for a playlist of media files or on-demand streams consists of multiple periods, each with its own window. Each window spans the whole of the corresponding period, and typically has a default position at the start of the period. The properties of the periods and windows (e.g. their durations and whether the window is seekable) will often only become known when the player starts buffering the corresponding file or stream.

## Live stream with limited availability

![Example timeline for a live stream with limited availability](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-live-limited.svg)

A timeline for a live stream consists of a period whose duration is unknown, since it's continually extending as more content is broadcast. If content only remains available for a limited period of time then the window may start at a non-zero position, defining the region of content that can still be played. The window will return true from `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isLive()` to indicate it's a live stream and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isDynamic()` will be set to true as long as we expect changes to the live window. Its default position is typically near to the live edge (indicated by the black dot in the figure above).

## Live stream with indefinite availability

![Example timeline for a live stream with indefinite availability](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-live-indefinite.svg)

A timeline for a live stream with indefinite availability is similar to the [Live stream with limited availability](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#live-limited) case, except that the window starts at the beginning of the period to indicate that all of the previously broadcast content can still be played.

## Live stream with multiple periods

![Example timeline for a live stream with multiple periods](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-live-multi-period.svg)

This case arises when a live stream is explicitly divided into separate periods, for example at content boundaries. This case is similar to the [Live stream with limited availability](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#live-limited) case, except that the window may span more than one period. Multiple periods are also possible in the indefinite availability case.

## On-demand stream followed by live stream

![Example timeline for an on-demand stream followed by a live stream](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-advanced.svg)

This case is the concatenation of the [Single media file or on-demand stream](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#single-file) and [Live stream with multiple periods](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#multi-period) cases. When playback of the on-demand stream ends, playback of the live stream will start from its default position near the live edge.

## On-demand stream with mid-roll ads

![Example timeline for an on-demand stream with mid-roll ad groups](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-single-file-midrolls.svg)

This case includes mid-roll ad groups, which are defined as part of the timeline's single period. The period can be queried for information about the ad groups and the ads they contain.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` Holds information about a period in a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi class https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.RemotableTimeline : https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` A concrete class of `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` to restore a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` instance from a `https://developer.android.com/reference/android/os/Bundle.html` sent by another process via `https://developer.android.com/reference/android/os/IBinder.html`. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` Holds information about a window in a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |

| ### Constants |
|---|---|
| `const https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#EMPTY()` An empty timeline. |

| ### Protected constructors |
|---|
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#Timeline()()` |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#copyWithSingleWindow(int)(windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a copy of this timeline containing just the single specified `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#equals(java.lang.Object)(obj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi [fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#fromBundle(android.os.Bundle))(bundle: https://developer.android.com/reference/android/os/Bundle.html!)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#fromBundle(android.os.Bundle,int)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#fromBundle(android.os.Bundle,int)(bundle: https://developer.android.com/reference/android/os/Bundle.html!, interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Restores a `Timeline` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getFirstWindowIndex(boolean)(shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns the index of the first window in the playback order depending on whether shuffling is enabled. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getIndexOfPeriod(java.lang.Object)(uid: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` Returns the index of the period identified by its unique `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period#uid()`, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the period is not in the timeline. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getLastWindowIndex(boolean)(shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Returns the index of the last window in the playback order depending on whether shuffling is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getNextPeriodIndex(int,androidx.media3.common.Timeline.Period,androidx.media3.common.Timeline.Window,int,boolean)( periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!, window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns the index of the period after the period at index `periodIndex` depending on the `repeatMode` and whether shuffling is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getNextWindowIndex(int,int,boolean)( windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` 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/kotlin/androidx/media3/common/Timeline.Period!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriod(int,androidx.media3.common.Timeline.Period)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!)` Populates a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` with data for the period at the specified index. |
| `abstract https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriod(int,androidx.media3.common.Timeline.Period,boolean)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!, setIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Populates a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` with data for the period at the specified index. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodByUid(java.lang.Object,androidx.media3.common.Timeline.Period)(periodUid: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!)` Populates a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` with data for the period with the specified unique identifier. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodCount()()` Returns the number of periods in the timeline. |
| `https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html!>!` | `@https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/common/Timeline#getPeriodPosition(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long))( window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!, windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, windowPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)` instead. <br /> |
| `https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html!>?` | `@https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/common/Timeline#getPeriodPosition(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long))( window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!, windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, windowPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, defaultPositionProjectionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long)` instead. <br /> |
| `https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)( window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!, windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, windowPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Calls `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)` with a zero default position projection. |
| `https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html!>?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long)( window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!, windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, windowPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, defaultPositionProjectionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Converts `(windowIndex, windowPositionUs)` to the corresponding `(periodUid, periodPositionUs)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPreviousWindowIndex(int,int,boolean)( windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns the index of the window before the window at index `windowIndex` depending on the `repeatMode` and whether shuffling is enabled. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getUidOfPeriod(int)(periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the unique id of the period identified by its index in the timeline. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getWindow(int,androidx.media3.common.Timeline.Window)(windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!)` Populates a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` with data for the window at the specified index. |
| `abstract https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getWindow(int,androidx.media3.common.Timeline.Window,long)( windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!, defaultPositionProjectionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Populates a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` with data for the window at the specified index. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getWindowCount()()` Returns the number of windows in the timeline. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#isEmpty()()` Returns whether the timeline is empty. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#isLastPeriod(int,androidx.media3.common.Timeline.Period,androidx.media3.common.Timeline.Window,int,boolean)( periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!, window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Returns whether the given period is the last period of the timeline depending on the ` repeatMode` and whether shuffling is enabled. |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi [toBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#toBundle())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#toBundle(int)` instead. <br /> |
| `https://developer.android.com/reference/android/os/Bundle.html!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#toBundle(int)(interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a `https://developer.android.com/reference/android/os/Bundle.html` representing the information stored in this object. |

## Constants

### EMPTY

```
const val EMPTY: Timeline!
```

An empty timeline.

## Protected constructors

### Timeline

```
@UnstableApi
protected Timeline()
```

## Public functions

### copyWithSingleWindow

```
@UnstableApi
fun copyWithSingleWindow(windowIndex: Int): Timeline!
```

Returns a copy of this timeline containing just the single specified `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window`.

The method returns the same instance if there is only one window.

| Parameters |
|---|---|
| `windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` to include in the copy. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` with just the single specified `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window`. |

### equals

```
fun equals(obj: Any?): Boolean
```

### fromBundle

```
@UnstableApi
java-static fun [fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#fromBundle(android.os.Bundle))(bundle: Bundle!): Timeline!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#fromBundle(android.os.Bundle,int)` instead.

### fromBundle

```
@UnstableApi
java-static fun fromBundle(bundle: Bundle!, interfaceVersion: Int): Timeline!
```

Restores a `Timeline` from a `https://developer.android.com/reference/android/os/Bundle.html`.

| Parameters |
|---|---|
| `bundle: https://developer.android.com/reference/android/os/Bundle.html!` | The `https://developer.android.com/reference/android/os/Bundle.html`. |
| `interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the sending process. |

### getFirstWindowIndex

```
fun getFirstWindowIndex(shuffleModeEnabled: Boolean): Int
```

Returns the index of the first window in the playback order depending on whether shuffling is enabled.

| Parameters |
|---|---|
| `shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether shuffling is enabled. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the first window in the playback order, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the timeline is empty. |

### getIndexOfPeriod

```
abstract fun getIndexOfPeriod(uid: Any!): Int
```

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

| Parameters |
|---|---|
| `uid: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | A unique identifier for a period. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the period, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the period was not found. |

### getLastWindowIndex

```
fun getLastWindowIndex(shuffleModeEnabled: Boolean): Int
```

Returns the index of the last window in the playback order depending on whether shuffling is enabled.

| Parameters |
|---|---|
| `shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether shuffling is enabled. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the last window in the playback order, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if the timeline is empty. |

### getNextPeriodIndex

```
fun getNextPeriodIndex(
    periodIndex: Int,
    period: Timeline.Period!,
    window: Timeline.Window!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
): Int
```

Returns the index of the period after the period at index `periodIndex` depending on the `repeatMode` and whether shuffling is enabled.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Index of a period in the timeline. |
| `period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` to be used internally. Must not be null. |
| `window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` to be used internally. Must not be null. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A repeat mode. |
| `shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether shuffling is enabled. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the next period, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if this is the last period. |

### getNextWindowIndex

```
fun getNextWindowIndex(
    windowIndex: Int,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
): Int
```

Returns the index of the window after the window at index `windowIndex` depending on the `repeatMode` and whether shuffling is enabled.

| Parameters |
|---|---|
| `windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Index of a window in the timeline. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A repeat mode. |
| `shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether shuffling is enabled. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the next window, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if this is the last window. |

### getPeriod

```
fun getPeriod(periodIndex: Int, period: Timeline.Period!): Timeline.Period!
```

Populates a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` with data for the period at the specified index. `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period#id()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period#uid()` will be set to null.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the period. |
| `period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` to populate. Must not be null. |

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

### getPeriod

```
abstract fun getPeriod(periodIndex: Int, period: Timeline.Period!, setIds: Boolean): Timeline.Period!
```

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

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the period. |
| `period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` to populate. Must not be null. |
| `setIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period#id()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/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 |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | The populated `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period`, for convenience. |

### getPeriodByUid

```
fun getPeriodByUid(periodUid: Any!, period: Timeline.Period!): Timeline.Period!
```

Populates a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` with data for the period with the specified unique identifier.

| Parameters |
|---|---|
| `periodUid: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | The unique identifier of the period. |
| `period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` to populate. Must not be null. |

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

### getPeriodCount

```
abstract fun getPeriodCount(): Int
```

Returns the number of periods in the timeline.

### getPeriodPosition

```
@UnstableApi
@InlineMe(replacement = "this.getPeriodPositionUs(window, period, windowIndex, windowPositionUs)")
fun [getPeriodPosition](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPosition(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long))(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long
): Pair<Any!, Long!>!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)` instead.

### getPeriodPosition

```
@UnstableApi
@InlineMe(replacement = "this.getPeriodPositionUs("
              + "window, period, windowIndex, windowPositionUs, defaultPositionProjectionUs)")
fun [getPeriodPosition](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPosition(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long))(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long,
    defaultPositionProjectionUs: Long
): Pair<Any!, Long!>?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long,long)` instead.

### getPeriodPositionUs

```
fun getPeriodPositionUs(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long
): Pair<Any!, Long!>!
```

Calls `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriodPositionUs(androidx.media3.common.Timeline.Window,androidx.media3.common.Timeline.Period,int,long)` with a zero default position projection.

### getPeriodPositionUs

```
fun getPeriodPositionUs(
    window: Timeline.Window!,
    period: Timeline.Period!,
    windowIndex: Int,
    windowPositionUs: Long,
    defaultPositionProjectionUs: Long
): Pair<Any!, Long!>?
```

Converts `(windowIndex, windowPositionUs)` to the corresponding `(periodUid,
periodPositionUs)`. The returned `periodPositionUs` is constrained to be non-negative, and to be less than the containing period's duration if it is known.

| Parameters |
|---|---|
| `window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` that may be overwritten. |
| `period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` that may be overwritten. |
| `windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The window index. |
| `windowPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The window time, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` to use the window's default start position. |
| `defaultPositionProjectionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | If `windowPositionUs` is `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()`, the duration into the future by which the window's position should be projected. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/util/Pair.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html!>?` | The corresponding (periodUid, periodPositionUs), or null if `#windowPositionUs` is `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()`, `defaultPositionProjectionUs` is non-zero, and the window's position could not be projected by `defaultPositionProjectionUs`. |

### getPreviousWindowIndex

```
fun getPreviousWindowIndex(
    windowIndex: Int,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
): Int
```

Returns the index of the window before the window at index `windowIndex` depending on the `repeatMode` and whether shuffling is enabled.

| Parameters |
|---|---|
| `windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Index of a window in the timeline. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A repeat mode. |
| `shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether shuffling is enabled. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the previous window, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#INDEX_UNSET()` if this is the first window. |

### getUidOfPeriod

```
abstract fun getUidOfPeriod(periodIndex: Int): Any!
```

Returns the unique id of the period identified by its index in the timeline.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the period. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | The unique id of the period. |

### getWindow

```
fun getWindow(windowIndex: Int, window: Timeline.Window!): Timeline.Window!
```

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

| Parameters |
|---|---|
| `windowIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the window. |
| `window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` to populate. Must not be null. |

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

### getWindow

```
abstract fun getWindow(
    windowIndex: Int,
    window: Timeline.Window!,
    defaultPositionProjectionUs: Long
): Timeline.Window!
```

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

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

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

### getWindowCount

```
abstract fun getWindowCount(): Int
```

Returns the number of windows in the timeline.

### hashCode

```
fun hashCode(): Int
```

### isEmpty

```
fun isEmpty(): Boolean
```

Returns whether the timeline is empty.

### isLastPeriod

```
fun isLastPeriod(
    periodIndex: Int,
    period: Timeline.Period!,
    window: Timeline.Window!,
    @Player.RepeatMode repeatMode: Int,
    shuffleModeEnabled: Boolean
): Boolean
```

Returns whether the given period is the last period of the timeline depending on the `
repeatMode` and whether shuffling is enabled.

| Parameters |
|---|---|
| `periodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A period index. |
| `period: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` to be used internally. Must not be null. |
| `window: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window` to be used internally. Must not be null. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.RepeatMode repeatMode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A repeat mode. |
| `shuffleModeEnabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether shuffling is enabled. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether the period of the given index is the last period of the timeline. |

### toBundle

```
@UnstableApi
fun [toBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#toBundle())(): Bundle!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#toBundle(int)` instead.

### toBundle

```
@UnstableApi
fun toBundle(interfaceVersion: Int): Bundle!
```

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

The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getWindow(int,androidx.media3.common.Timeline.Window)` windows} and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#getPeriod(int,androidx.media3.common.Timeline.Period)` of an instance restored by `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline#fromBundle(android.os.Bundle)` may have missing fields as described in `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#toBundle(int)` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period#toBundle(int)`.

| Parameters |
|---|---|
| `interfaceVersion: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the receiving process. |