# Timeline.Period

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

*** ** * ** ***


```
public final class Timeline.Period
```

<br />

*** ** * ** ***

Holds information about a period in a `https://developer.android.com/reference/androidx/media3/common/Timeline`. A 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 figure below shows some of the information defined by a period, as well as how this information relates to a corresponding `https://developer.android.com/reference/androidx/media3/common/Timeline.Window` in the timeline.

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

## Summary

| ### Public fields |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#adPlaybackState()` The `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState` for all ads in this period. |
| `long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#durationUs()` The duration of this period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#id()` An identifier for the period. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#isPlaceholder()` Whether this period contains placeholder information because the real information has yet to be loaded. |
| `long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#originalDurationUs()` The original duration of this period in microseconds before any modification of the period end (for example by clipping), or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#positionInWindowUs()` The position of the start of this period relative to the start of the window to which it belongs, in microseconds. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#uid()` A unique identifier for the period. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#windowIndex()` The index of the window to which this period belongs. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#Period()()` Creates a new instance with no ad playback state. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `static https://developer.android.com/reference/androidx/media3/common/Timeline.Period` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [fromBundle](https://developer.android.com/reference/androidx/media3/common/Timeline.Period#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.Period#fromBundle(android.os.Bundle,int)` instead. <br /> |
| `static https://developer.android.com/reference/androidx/media3/common/Timeline.Period` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#fromBundle(android.os.Bundle,int)(https://developer.android.com/reference/android/os/Bundle.html bundle, int interfaceVersion)` Restores a `Period` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdCountInAdGroup(int)(int adGroupIndex)` Returns the number of ads in the ad group at index `adGroupIndex`, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if not yet known. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdDurationUs(int,int)(int adGroupIndex, int adIndexInAdGroup)` Returns the duration of the ad at index `adIndexInAdGroup` in the ad group at ` adGroupIndex`, in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if not yet known. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdGroupCount()()` Returns the number of ad groups in the period. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdGroupIndexAfterPositionUs(long)(long positionUs)` Returns the index of the next ad group after `positionUs` in the period that has ads that should be played. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdGroupIndexForPositionUs(long)(long positionUs)` Returns the index of the ad group at or before `positionUs` in the period that should be played before the content at `positionUs`. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdGroupTimeUs(int)(int adGroupIndex)` Returns the time of the ad group at index `adGroupIndex` in the period, in microseconds. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdResumePositionUs()()` Returns the position offset in the first unplayed ad at which to begin playback, in microseconds. |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdState(int,int)(int adGroupIndex, int adIndexInAdGroup)` Returns the state of the ad at index `adIndexInAdGroup` in the ad group at ` adGroupIndex`, or `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState#AD_STATE_UNAVAILABLE()` if not yet known. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getAdsId()()` Returns the opaque identifier for ads played with this period, or `null` if unset. |
| `long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getContentResumeOffsetUs(int)(int adGroupIndex)` Returns the offset in microseconds which should be added to the content stream when resuming playback after the specified ad group. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getDurationMs()()` Returns the duration of the period in milliseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getDurationUs()()` Returns the duration of this period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getFirstAdIndexToPlay(int)(int adGroupIndex)` Returns the index of the first ad in the specified ad group that should be played, or the number of ads in the ad group if no ads should be played. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getNextAdIndexToPlay(int,int)(int adGroupIndex, int lastPlayedAdIndex)` Returns the index of the next ad in the specified ad group that should be played after playing `adIndexInAdGroup`, or the number of ads in the ad group if no later ads should be played. |
| `long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getOriginalDurationMs()()` Returns the original duration of the period in milliseconds before any modification of the period end, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getOriginalDurationUs()()` Returns the original duration of this period in microseconds before any modification of the period end, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getPositionInWindowMs()()` Returns the position of the start of this period relative to the start of the window to which it belongs, in milliseconds. |
| `long` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getPositionInWindowUs()()` Returns the position of the start of this period relative to the start of the window to which it belongs, in microseconds. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#getRemovedAdGroupCount()()` Returns the number of removed ad groups in the period. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#hasPlayedAdGroup(int)(int adGroupIndex)` Returns whether all ads in the ad group at index `adGroupIndex` have been played, skipped or failed. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#hashCode()()` |
| `boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#isLivePostrollPlaceholder(int)(int adGroupIndex)` Returns whether the ad group at the given ad group index is a live postroll placeholder. |
| `boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#isServerSideInsertedAdGroup(int)(int adGroupIndex)` Returns whether the ad group at index `adGroupIndex` is server-side inserted and part of the content stream. |
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [set](https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long))( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html id, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html uid, int windowIndex, long durationUs, long positionInWindowUs )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long,androidx.media3.common.AdPlaybackState,boolean,long)` instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [set](https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long,androidx.media3.common.AdPlaybackState,boolean))( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html id, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html uid, int windowIndex, long durationUs, long positionInWindowUs, https://developer.android.com/reference/androidx/media3/common/AdPlaybackState adPlaybackState, boolean isPlaceholder )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long,androidx.media3.common.AdPlaybackState,boolean,long)` instead. <br /> |
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long,androidx.media3.common.AdPlaybackState,boolean,long)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html id, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html uid, int windowIndex, long durationUs, long positionInWindowUs, https://developer.android.com/reference/androidx/media3/common/AdPlaybackState adPlaybackState, boolean isPlaceholder, long originalDurationUs )` Sets the data held by this period. |
| `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.Period#toBundle())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#toBundle(int)` instead. <br /> |
| `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.Period#toBundle(int)(int interfaceVersion)` Returns a `https://developer.android.com/reference/android/os/Bundle.html` representing the information stored in this object. |

## Public fields

### adPlaybackState

```
@UnstableApi
public AdPlaybackState adPlaybackState
```

The `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState` for all ads in this period.

### durationUs

```
@UnstableApi
public long durationUs
```

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

This is the playout duration of the period. It may be different from `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#originalDurationUs()` if the period end is modified.

### id

```
public @Nullable Object id
```

An identifier for the period. Not necessarily unique. May be null if the ids of the period are not required.

### isPlaceholder

```
public boolean isPlaceholder
```

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

### originalDurationUs

```
@UnstableApi
public long originalDurationUs
```

The original duration of this period in microseconds before any modification of the period end (for example by clipping), or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown.

### positionInWindowUs

```
@UnstableApi
public long positionInWindowUs
```

The position of the start of this period relative to the start of the window to which it belongs, in microseconds. May be negative if the start of the period is not within the window.

### uid

```
public @Nullable Object uid
```

A unique identifier for the period. May be null if the ids of the period are not required.

### windowIndex

```
public int windowIndex
```

The index of the window to which this period belongs.

## Public constructors

### Period

```
public Period()
```

Creates a new instance with no ad playback state.

## Public methods

### equals

```
public boolean equals(@Nullable Object obj)
```

### fromBundle

```
@UnstableApi
public static Timeline.Period [fromBundle](https://developer.android.com/reference/androidx/media3/common/Timeline.Period#fromBundle(android.os.Bundle))(Bundle bundle)
```

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

### fromBundle

```
@UnstableApi
public static Timeline.Period fromBundle(Bundle bundle, int interfaceVersion)
```

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/android/os/Bundle.html bundle` | The `https://developer.android.com/reference/android/os/Bundle.html`. |
| `int interfaceVersion` | The `https://developer.android.com/reference/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the sending process. |

### getAdCountInAdGroup

```
public int getAdCountInAdGroup(int adGroupIndex)
```

Returns the number of ads in the ad group at index `adGroupIndex`, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if not yet known.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |

| Returns |
|---|---|
| `int` | The number of ads in the ad group, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if not yet known. |

### getAdDurationUs

```
public long getAdDurationUs(int adGroupIndex, int adIndexInAdGroup)
```

Returns the duration of the ad at index `adIndexInAdGroup` in the ad group at `
adGroupIndex`, in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if not yet known.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |
| `int adIndexInAdGroup` | The ad index in the ad group. |

| Returns |
|---|---|
| `long` | The duration of the ad, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if not yet known. |

### getAdGroupCount

```
public int getAdGroupCount()
```

Returns the number of ad groups in the period.

### getAdGroupIndexAfterPositionUs

```
public int getAdGroupIndexAfterPositionUs(long positionUs)
```

Returns the index of the next ad group after `positionUs` in the period that has ads that should be played. Returns `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if there is no such ad group.

| Parameters |
|---|---|
| `long positionUs` | The period position after which to find an ad group, in microseconds. |

| Returns |
|---|---|
| `int` | The index of the ad group, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`. |

### getAdGroupIndexForPositionUs

```
public int getAdGroupIndexForPositionUs(long positionUs)
```

Returns the index of the ad group at or before `positionUs` in the period that should be played before the content at `positionUs`. Returns `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if the ad group at or before `positionUs` has no ads remaining to be played, or if there is no such ad group.

| Parameters |
|---|---|
| `long positionUs` | The period position at or before which to find an ad group, in microseconds. |

| Returns |
|---|---|
| `int` | The index of the ad group, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`. |

### getAdGroupTimeUs

```
public long getAdGroupTimeUs(int adGroupIndex)
```

Returns the time of the ad group at index `adGroupIndex` in the period, in microseconds.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |

| Returns |
|---|---|
| `long` | The time of the ad group at the index relative to the start of the enclosing `https://developer.android.com/reference/androidx/media3/common/Timeline.Period`, in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_END_OF_SOURCE()` for a post-roll ad group. |

### getAdResumePositionUs

```
public long getAdResumePositionUs()
```

Returns the position offset in the first unplayed ad at which to begin playback, in microseconds.

### getAdState

```
@UnstableApi
public int getAdState(int adGroupIndex, int adIndexInAdGroup)
```

Returns the state of the ad at index `adIndexInAdGroup` in the ad group at `
adGroupIndex`, or `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState#AD_STATE_UNAVAILABLE()` if not yet known.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |
| `int adIndexInAdGroup` | The index of the ad in the ad group. |

| Returns |
|---|---|
| `int` | The state of the ad, or `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState#AD_STATE_UNAVAILABLE()` if not yet known. |

### getAdsId

```
public @Nullable Object getAdsId()
```

Returns the opaque identifier for ads played with this period, or `null` if unset.

### getContentResumeOffsetUs

```
@UnstableApi
public long getContentResumeOffsetUs(int adGroupIndex)
```

Returns the offset in microseconds which should be added to the content stream when resuming playback after the specified ad group.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |

| Returns |
|---|---|
| `long` | The offset that should be added to the content stream, in microseconds. |

### getDurationMs

```
public long getDurationMs()
```

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

### getDurationUs

```
public long getDurationUs()
```

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

### getFirstAdIndexToPlay

```
public int getFirstAdIndexToPlay(int adGroupIndex)
```

Returns the index of the first ad in the specified ad group that should be played, or the number of ads in the ad group if no ads should be played.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |

| Returns |
|---|---|
| `int` | The index of the first ad that should be played, or the number of ads in the ad group if no ads should be played. |

### getNextAdIndexToPlay

```
public int getNextAdIndexToPlay(int adGroupIndex, int lastPlayedAdIndex)
```

Returns the index of the next ad in the specified ad group that should be played after playing `adIndexInAdGroup`, or the number of ads in the ad group if no later ads should be played.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |
| `int lastPlayedAdIndex` | The last played ad index in the ad group. |

| Returns |
|---|---|
| `int` | The index of the next ad that should be played, or the number of ads in the ad group if the ad group does not have any ads remaining to play. |

### getOriginalDurationMs

```
@UnstableApi
public long getOriginalDurationMs()
```

Returns the original duration of the period in milliseconds before any modification of the period end, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown.

### getOriginalDurationUs

```
@UnstableApi
public long getOriginalDurationUs()
```

Returns the original duration of this period in microseconds before any modification of the period end, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown.

### getPositionInWindowMs

```
public long getPositionInWindowMs()
```

Returns the position of the start of this period relative to the start of the window to which it belongs, in milliseconds. May be negative if the start of the period is not within the window.

### getPositionInWindowUs

```
public long getPositionInWindowUs()
```

Returns the position of the start of this period relative to the start of the window to which it belongs, in microseconds. May be negative if the start of the period is not within the window.

### getRemovedAdGroupCount

```
public int getRemovedAdGroupCount()
```

Returns the number of removed ad groups in the period. Ad groups with indices between `
0` (inclusive) and `removedAdGroupCount` (exclusive) will be empty.

### hasPlayedAdGroup

```
public boolean hasPlayedAdGroup(int adGroupIndex)
```

Returns whether all ads in the ad group at index `adGroupIndex` have been played, skipped or failed.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |

| Returns |
|---|---|
| `boolean` | Whether all ads in the ad group at index `adGroupIndex` have been played, skipped or failed. |

### hashCode

```
public int hashCode()
```

### isLivePostrollPlaceholder

```
@UnstableApi
public boolean isLivePostrollPlaceholder(int adGroupIndex)
```

Returns whether the ad group at the given ad group index is a live postroll placeholder.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |

| Returns |
|---|---|
| `boolean` | True if the ad group at the given index is a live postroll placeholder. |

### isServerSideInsertedAdGroup

```
@UnstableApi
public boolean isServerSideInsertedAdGroup(int adGroupIndex)
```

Returns whether the ad group at index `adGroupIndex` is server-side inserted and part of the content stream.

| Parameters |
|---|---|
| `int adGroupIndex` | The ad group index. |

| Returns |
|---|---|
| `boolean` | Whether this ad group is server-side inserted and part of the content stream. |

### set

```
@CanIgnoreReturnValue
@UnstableApi
public Timeline.Period [set](https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long))(
    @Nullable Object id,
    @Nullable Object uid,
    int windowIndex,
    long durationUs,
    long positionInWindowUs
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long,androidx.media3.common.AdPlaybackState,boolean,long)` instead.

### set

```
@CanIgnoreReturnValue
@UnstableApi
public Timeline.Period [set](https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long,androidx.media3.common.AdPlaybackState,boolean))(
    @Nullable Object id,
    @Nullable Object uid,
    int windowIndex,
    long durationUs,
    long positionInWindowUs,
    AdPlaybackState adPlaybackState,
    boolean isPlaceholder
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#set(java.lang.Object,java.lang.Object,int,long,long,androidx.media3.common.AdPlaybackState,boolean,long)` instead.

Sets the data held by this period.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html id` | An identifier for the period. Not necessarily unique. May be null if the ids of the period are not required. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html uid` | A unique identifier for the period. May be null if the ids of the period are not required. |
| `int windowIndex` | The index of the window to which this period belongs. |
| `long durationUs` | The duration of this period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `long positionInWindowUs` | The position of the start of this period relative to the start of the window to which it belongs, in microseconds. May be negative if the start of the period is not within the window. |
| `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState adPlaybackState` | The state of the period's ads, or `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState#NONE()` if there are no ads. |
| `boolean isPlaceholder` | Whether this period contains placeholder information because the real information has yet to be loaded. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` | This period, for convenience. |

### set

```
@CanIgnoreReturnValue
@UnstableApi
public Timeline.Period set(
    @Nullable Object id,
    @Nullable Object uid,
    int windowIndex,
    long durationUs,
    long positionInWindowUs,
    AdPlaybackState adPlaybackState,
    boolean isPlaceholder,
    long originalDurationUs
)
```

Sets the data held by this period.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html id` | An identifier for the period. Not necessarily unique. May be null if the ids of the period are not required. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html uid` | A unique identifier for the period. May be null if the ids of the period are not required. |
| `int windowIndex` | The index of the window to which this period belongs. |
| `long durationUs` | The duration of this period in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |
| `long positionInWindowUs` | The position of the start of this period relative to the start of the window to which it belongs, in microseconds. May be negative if the start of the period is not within the window. |
| `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState adPlaybackState` | The state of the period's ads, or `https://developer.android.com/reference/androidx/media3/common/AdPlaybackState#NONE()` if there are no ads. |
| `boolean isPlaceholder` | Whether this period contains placeholder information because the real information has yet to be loaded. |
| `long originalDurationUs` | The original duration of this period in microseconds before any modification of the period end (for example by clipping), or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if unknown. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Timeline.Period` | This period, for convenience. |

### toBundle

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

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

### toBundle

```
@UnstableApi
public Bundle toBundle(int interfaceVersion)
```

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/androidx/media3/common/Timeline.Period#id()` and `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#uid()` fields so these fields of an instance restored by `https://developer.android.com/reference/androidx/media3/common/Timeline.Period#fromBundle(android.os.Bundle)` will always be `null`.

| Parameters |
|---|---|
| `int interfaceVersion` | The `https://developer.android.com/reference/androidx/media3/common/MediaLibraryInfo#INTERFACE_VERSION()` of the receiving process. |