# Timeline.Window

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.Window)

*** ** * ** ***


```
class Timeline.Window
```

<br />

*** ** * ** ***

Holds information about a window in a `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. A window usually corresponds to one playlist item and defines a region of media currently available for playback along with additional information such as whether seeking is supported within the window. The figure below shows some of the information defined by a window, as well as how this information relates to corresponding `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Period` in the timeline.

![Information defined by a timeline window](https://developer.android.com/static/images/reference/androidx/media3/common/timeline-window.svg)

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#SINGLE_WINDOW_UID()` A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#uid()` for a window that must be used for single-window `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#Window()()` Creates window. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#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.Window!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi [fromBundle](https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#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.Window#fromBundle(android.os.Bundle,int)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#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 `Window` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getCurrentUnixTimeMs()()` Returns the current time in milliseconds since the Unix epoch. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getDefaultPositionMs()()` Returns the default position relative to the start of the window at which to begin playback, in milliseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getDefaultPositionUs()()` Returns the default position relative to the start of the window at which to begin playback, in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getDurationMs()()` Returns the duration of the window in milliseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getDurationUs()()` Returns the duration of this window in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getPositionInFirstPeriodMs()()` Returns the position of the start of this window relative to the start of the first period belonging to it, in milliseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getPositionInFirstPeriodUs()()` Returns the position of the start of this window relative to the start of the first period belonging to it, in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isLive()()` Returns whether this is a live stream. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#set(java.lang.Object,androidx.media3.common.MediaItem,java.lang.Object,long,long,long,boolean,boolean,androidx.media3.common.MediaItem.LiveConfiguration,long,long,int,int,long)( uid: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, mediaItem: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem?, manifest: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?, presentationStartTimeMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, windowStartTimeMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, elapsedRealtimeEpochOffsetMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, isSeekable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, isDynamic: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, liveConfiguration: https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LiveConfiguration?, defaultPositionUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, firstPeriodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, lastPeriodIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, positionInFirstPeriodUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html )` Sets the data held by this window. |
| `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.Window#toBundle())()` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#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.Window#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. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#defaultPositionUs()` The default position relative to the start of the window at which to begin playback, in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#durationUs()` The duration of this window in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#elapsedRealtimeEpochOffsetMs()` The offset between `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` and the time since the Unix epoch according to the clock of the media origin server, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown or not applicable. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#firstPeriodIndex()` The index of the first period that belongs to this window. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isDynamic()` Whether this window may change when the timeline is updated. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isPlaceholder()` Whether this window contains placeholder information because the real information has yet to be loaded. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isSeekable()` Whether it's possible to seek within this window. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#lastPeriodIndex()` The index of the last period that belongs to this window. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LiveConfiguration?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#liveConfiguration()` The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LiveConfiguration` that is used or null if `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isLive()` returns false. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#manifest()` The manifest of the window. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#mediaItem()` The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` associated to the window. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#positionInFirstPeriodUs()` The position of the start of this window relative to the start of the first period belonging to it, in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#presentationStartTimeMs()` The start time of the presentation to which this window belongs in milliseconds since the Unix epoch, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown or not applicable. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#tag()` **This property is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#tag()` of `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#mediaItem()` instead. <br /> |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#uid()` A unique identifier for the window. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#windowStartTimeMs()` The window's start time in milliseconds since the Unix epoch, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown or not applicable. |

## Constants

### SINGLE_WINDOW_UID

```
const val SINGLE_WINDOW_UID: Any!
```

A `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#uid()` for a window that must be used for single-window `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`.

## Public constructors

### Window

```
Window()
```

Creates window.

## Public functions

### equals

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

### fromBundle

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

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

### fromBundle

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

Restores a `Window` 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. |

### getCurrentUnixTimeMs

```
fun getCurrentUnixTimeMs(): Long
```

Returns the current time in milliseconds since the Unix epoch.

This method applies `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#elapsedRealtimeEpochOffsetMs()` made available by the media such that this time corresponds to the clock of the media origin server.

### getDefaultPositionMs

```
fun getDefaultPositionMs(): Long
```

Returns the default position relative to the start of the window at which to begin playback, in milliseconds. May be `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if and only if the window was populated with a non-zero default position projection, and if the specified projection cannot be performed whilst remaining within the bounds of the window.

### getDefaultPositionUs

```
fun getDefaultPositionUs(): Long
```

Returns the default position relative to the start of the window at which to begin playback, in microseconds. May be `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if and only if the window was populated with a non-zero default position projection, and if the specified projection cannot be performed whilst remaining within the bounds of the window.

### getDurationMs

```
fun getDurationMs(): Long
```

Returns the duration of the window in milliseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown.

### getDurationUs

```
fun getDurationUs(): Long
```

Returns the duration of this window in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown.

### getPositionInFirstPeriodMs

```
fun getPositionInFirstPeriodMs(): Long
```

Returns the position of the start of this window relative to the start of the first period belonging to it, in milliseconds.

### getPositionInFirstPeriodUs

```
fun getPositionInFirstPeriodUs(): Long
```

Returns the position of the start of this window relative to the start of the first period belonging to it, in microseconds.

### hashCode

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

### isLive

```
fun isLive(): Boolean
```

Returns whether this is a live stream.

### set

```
@CanIgnoreReturnValue
@UnstableApi
fun set(
    uid: Any!,
    mediaItem: MediaItem?,
    manifest: Any?,
    presentationStartTimeMs: Long,
    windowStartTimeMs: Long,
    elapsedRealtimeEpochOffsetMs: Long,
    isSeekable: Boolean,
    isDynamic: Boolean,
    liveConfiguration: MediaItem.LiveConfiguration?,
    defaultPositionUs: Long,
    durationUs: Long,
    firstPeriodIndex: Int,
    lastPeriodIndex: Int,
    positionInFirstPeriodUs: Long
): Timeline.Window!
```

Sets the data held by this window.

### toBundle

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

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#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.

It omits the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#uid()` and `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#manifest()` fields. The `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#uid()` of an instance restored by `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#fromBundle(android.os.Bundle)` will be a fake `https://developer.android.com/reference/java/lang/Object.html` and the `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#manifest()` of the instance will be `null`.

| 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. |

## Public properties

### defaultPositionUs

```
@UnstableApi
val defaultPositionUs: Long
```

The default position relative to the start of the window at which to begin playback, in microseconds. May be `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if and only if the window was populated with a non-zero default position projection, and if the specified projection cannot be performed whilst remaining within the bounds of the window.

### durationUs

```
@UnstableApi
val durationUs: Long
```

The duration of this window in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown.

### elapsedRealtimeEpochOffsetMs

```
val elapsedRealtimeEpochOffsetMs: Long
```

The offset between `https://developer.android.com/reference/android/os/SystemClock.html#elapsedRealtime()` and the time since the Unix epoch according to the clock of the media origin server, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown or not applicable.

Note that the current Unix time can be retrieved using `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#getCurrentUnixTimeMs()` and is calculated as `SystemClock.elapsedRealtime() + elapsedRealtimeEpochOffsetMs`.

### firstPeriodIndex

```
val firstPeriodIndex: Int
```

The index of the first period that belongs to this window.

### isDynamic

```
val isDynamic: Boolean
```

Whether this window may change when the timeline is updated.

### isPlaceholder

```
val isPlaceholder: Boolean
```

Whether this window contains placeholder information because the real information has yet to be loaded.

### isSeekable

```
val isSeekable: Boolean
```

Whether it's possible to seek within this window.

### lastPeriodIndex

```
val lastPeriodIndex: Int
```

The index of the last period that belongs to this window.

### liveConfiguration

```
val liveConfiguration: MediaItem.LiveConfiguration?
```

The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LiveConfiguration` that is used or null if `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#isLive()` returns false.

### manifest

```
val manifest: Any?
```

The manifest of the window. May be `null`.

The concrete type depends on the media sources producing the timeline window. Examples provided by Media3 media source modules are `
androidx.media3.exoplayer.dash.manifest.DashManifest`, `
androidx.media3.exoplayer.hls.HlsManifest` and `
androidx.media3.exoplayer.smoothstreaming.SSManifest`.

### mediaItem

```
val mediaItem: MediaItem!
```

The `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem` associated to the window. Not necessarily unique.

### positionInFirstPeriodUs

```
@UnstableApi
val positionInFirstPeriodUs: Long
```

The position of the start of this window relative to the start of the first period belonging to it, in microseconds.

### presentationStartTimeMs

```
val presentationStartTimeMs: Long
```

The start time of the presentation to which this window belongs in milliseconds since the Unix epoch, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown or not applicable. For informational purposes only.

### tag

```
@UnstableApi
val tag: Any?
```

> [!CAUTION]
> **This property is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LocalConfiguration#tag()` of `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#mediaItem()` instead.

### uid

```
val uid: Any!
```

A unique identifier for the window. Single-window `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline` must use `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline.Window#SINGLE_WINDOW_UID()`.

### windowStartTimeMs

```
val windowStartTimeMs: Long
```

The window's start time in milliseconds since the Unix epoch, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET()` if unknown or not applicable.