PlayerTransferState


@UnstableApi
public final class PlayerTransferState


Holds a snapshot of a player's transferable state.

We define transferable state to be state that should be carried over from one player to another when transferring playback. For example, the media playlist and the playback position are part of the transferable state. However, the buffering position is part of the player's state but it's not state we carry over when moving playback.

This class is useful when moving playback across devices. For example, across an Android device and a Cast receiver.

Summary

Nested types

public final class PlayerTransferState.Builder

Builder for PlayerTransferState.

Public fields

final int
final long
final ImmutableList<MediaItem>
final boolean
final PlaybackParameters
final int
final boolean

Public methods

PlayerTransferState.Builder

Returns a Builder pre-populated with the current state values.

static PlayerTransferState.Builder

Creates a new Builder that's pre-populated with the values from the given Player.

boolean
static PlayerTransferState

Equivalent to builderFromPlayer(player).build().

int

Returns the current media item index.

long

Returns the current position.

ImmutableList<MediaItem>

Returns the media items.

boolean

Returns the play when ready value.

PlaybackParameters

Returns the playback parameters.

int

Returns the repeat mode.

boolean

Returns the shuffle mode enabled value.

int
void

Applies this state to a given Player instance by calling the corresponding setters.

Public fields

currentMediaItemIndex

public final int currentMediaItemIndex

currentPosition

public final long currentPosition

mediaItems

public final ImmutableList<MediaItemmediaItems

playWhenReady

public final boolean playWhenReady

playbackParameters

public final PlaybackParameters playbackParameters

repeatMode

public final int repeatMode

shuffleModeEnabled

public final boolean shuffleModeEnabled

Public methods

buildUpon

public PlayerTransferState.Builder buildUpon()

Returns a Builder pre-populated with the current state values.

builderFromPlayer

public static PlayerTransferState.Builder builderFromPlayer(Player player)

Creates a new Builder that's pre-populated with the values from the given Player.

Parameters
Player player

The Player instance to populate the builder from.

Returns
PlayerTransferState.Builder

A new Builder instance populated with the given player's current state.

equals

public boolean equals(@Nullable Object o)

fromPlayer

public static PlayerTransferState fromPlayer(Player player)

Equivalent to builderFromPlayer(player).build().

Returns
PlayerTransferState

A PlayerTransferState whose contents are populated with the state from the given Player.

getCurrentMediaItemIndex

public int getCurrentMediaItemIndex()

Returns the current media item index.

getCurrentPosition

public long getCurrentPosition()

Returns the current position.

getMediaItems

public ImmutableList<MediaItemgetMediaItems()

Returns the media items.

getPlayWhenReady

public boolean getPlayWhenReady()

Returns the play when ready value.

getPlaybackParameters

public PlaybackParameters getPlaybackParameters()

Returns the playback parameters.

getRepeatMode

public int getRepeatMode()

Returns the repeat mode.

getShuffleModeEnabled

public boolean getShuffleModeEnabled()

Returns the shuffle mode enabled value.

hashCode

public int hashCode()

setToPlayer

public void setToPlayer(Player player)

Applies this state to a given Player instance by calling the corresponding setters.

Parameters
Player player

The Player instance to which the state should be applied.