# Player.PositionInfo

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/Player.java+class:androidx.media3.common.Player.PositionInfo)

*** ** * ** ***


```
public final class Player.PositionInfo
```

<br />

*** ** * ** ***

Position info describing a playback position involved in a discontinuity.

## Summary

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#adGroupIndex()` The ad group index if the playback position is within an ad, `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` otherwise. |
| `final int` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#adIndexInAdGroup()` The index of the ad within the ad group if the playback position is within an ad, `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` otherwise. |
| `final long` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#contentPositionMs()` The content position, in milliseconds. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/MediaItem` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#mediaItem()` The media item, or `null` if the timeline is `https://developer.android.com/reference/androidx/media3/common/Timeline#isEmpty()`. |
| `final int` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#mediaItemIndex()` The media item index. |
| `final int` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#periodIndex()` The period index. |
| `final @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/Player.PositionInfo#periodUid()` The UID of the period, or `null` if the timeline is `https://developer.android.com/reference/androidx/media3/common/Timeline#isEmpty()`. |
| `final long` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#positionMs()` The playback position, in milliseconds. |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#windowIndex()` **This field is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#mediaItemIndex()` instead. <br /> |
| `final @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/Player.PositionInfo#windowUid()` The UID of the window, or `null` if the timeline is `https://developer.android.com/reference/androidx/media3/common/Timeline#isEmpty()`. |

| ### Public constructors |
|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [PositionInfo](https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#PositionInfo(java.lang.Object,int,java.lang.Object,int,long,long,int,int))( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html windowUid, int mediaItemIndex, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html periodUid, int periodIndex, long positionMs, long contentPositionMs, int adGroupIndex, int adIndexInAdGroup )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#PositionInfo(java.lang.Object,int,androidx.media3.common.MediaItem,java.lang.Object,int,long,long,int,int)` instead. <br /> |
| `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#PositionInfo(java.lang.Object,int,androidx.media3.common.MediaItem,java.lang.Object,int,long,long,int,int)( @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html windowUid, int mediaItemIndex, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/MediaItem mediaItem, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html periodUid, int periodIndex, long positionMs, long contentPositionMs, int adGroupIndex, int adIndexInAdGroup )` Creates an instance. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html o)` |
| `boolean` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#equalsForBundling(androidx.media3.common.Player.PositionInfo)(https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo other)` Returns whether this position info and the other position info would result in the same `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#toBundle(int)`. |
| `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#filterByAvailableCommands(boolean,boolean)( boolean canAccessCurrentMediaItem, boolean canAccessTimeline )` Returns a copy of this position info, filtered by the specified available commands. |
| `static https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi [fromBundle](https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#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/Player.PositionInfo#fromBundle(android.os.Bundle,int)` instead. <br /> |
| `static https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#fromBundle(android.os.Bundle,int)(https://developer.android.com/reference/android/os/Bundle.html bundle, int interfaceVersion)` Restores a `PositionInfo` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#hashCode()()` |
| `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/Player.PositionInfo#toBundle())()` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#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/Player.PositionInfo#toBundle(int)(int interfaceVersion)` Returns a `https://developer.android.com/reference/android/os/Bundle.html` representing the information stored in this object. |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#toString()()` |

## Public fields

### adGroupIndex

```
public final int adGroupIndex
```

The ad group index if the playback position is within an ad, `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` otherwise.

### adIndexInAdGroup

```
public final int adIndexInAdGroup
```

The index of the ad within the ad group if the playback position is within an ad, `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` otherwise.

### contentPositionMs

```
public final long contentPositionMs
```

The content position, in milliseconds.

If `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#adGroupIndex()` is `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()`, this is the same as `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#positionMs()`.

### mediaItem

```
@UnstableApi
public final @Nullable MediaItem mediaItem
```

The media item, or `null` if the timeline is `https://developer.android.com/reference/androidx/media3/common/Timeline#isEmpty()`.

### mediaItemIndex

```
public final int mediaItemIndex
```

The media item index.

### periodIndex

```
public final int periodIndex
```

The period index.

### periodUid

```
public final @Nullable Object periodUid
```

The UID of the period, or `null` if the timeline is `https://developer.android.com/reference/androidx/media3/common/Timeline#isEmpty()`.

### positionMs

```
public final long positionMs
```

The playback position, in milliseconds.

### windowIndex

```
@UnstableApi
public final int windowIndex
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#mediaItemIndex()` instead.

### windowUid

```
public final @Nullable Object windowUid
```

The UID of the window, or `null` if the timeline is `https://developer.android.com/reference/androidx/media3/common/Timeline#isEmpty()`.

## Public constructors

### PositionInfo

```
@UnstableApi
public [PositionInfo](https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#PositionInfo(java.lang.Object,int,java.lang.Object,int,long,long,int,int))(
    @Nullable Object windowUid,
    int mediaItemIndex,
    @Nullable Object periodUid,
    int periodIndex,
    long positionMs,
    long contentPositionMs,
    int adGroupIndex,
    int adIndexInAdGroup
)
```

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

### PositionInfo

```
@UnstableApi
public PositionInfo(
    @Nullable Object windowUid,
    int mediaItemIndex,
    @Nullable MediaItem mediaItem,
    @Nullable Object periodUid,
    int periodIndex,
    long positionMs,
    long contentPositionMs,
    int adGroupIndex,
    int adIndexInAdGroup
)
```

Creates an instance.

## Public methods

### equals

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

### equalsForBundling

```
@UnstableApi
public boolean equalsForBundling(Player.PositionInfo other)
```

Returns whether this position info and the other position info would result in the same `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#toBundle(int)`.

### filterByAvailableCommands

```
@UnstableApi
public Player.PositionInfo filterByAvailableCommands(
    boolean canAccessCurrentMediaItem,
    boolean canAccessTimeline
)
```

Returns a copy of this position info, filtered by the specified available commands.

The filtered fields are reset to their default values.

The return value may be the same object if nothing is filtered.

| Parameters |
|---|---|
| `boolean canAccessCurrentMediaItem` | Whether `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_CURRENT_MEDIA_ITEM()` is available. |
| `boolean canAccessTimeline` | Whether `https://developer.android.com/reference/androidx/media3/common/Player#COMMAND_GET_TIMELINE()` is available. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo` | The filtered position info. |

### fromBundle

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

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

### fromBundle

```
@UnstableApi
public static Player.PositionInfo fromBundle(Bundle bundle, int interfaceVersion)
```

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

### hashCode

```
public int hashCode()
```

### toBundle

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

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#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/Player.PositionInfo#windowUid()` and `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#periodUid()` fields. The `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#windowUid()` and `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#periodUid()` of an instance restored by `https://developer.android.com/reference/androidx/media3/common/Player.PositionInfo#fromBundle(android.os.Bundle,int)` will always be `null`.

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

### toString

```
public String toString()
```