CastPlayer
@UnstableApi
public final class CastPlayer extends ForwardingPlayer
Player implementation that can control playback both on the local device, and on a remote Cast device.
See RemoteCastPlayer for a Player that only supports playback on Cast receivers.
This class works by delegating playback to a dedicated player depending on Cast session availability. When a Cast session becomes available or unavailable, the following steps take place:
- The new active player is a
RemoteCastPlayerif a Cast session is active, or thelocal playerotherwise. - A customizable
TransferCallbackreceives both players to transfer state across players. - The inactive player is
stopped.
Summary
Nested types |
|---|
public final class CastPlayer.BuilderBuilder for |
public interface CastPlayer.TransferCallbackCallback for moving state across players when transferring playback upon Cast session availability changes. |
Constants |
|
|---|---|
static final DeviceInfo |
Same as |
Public constructors |
|---|
This method is deprecated. Use |
This method is deprecated. Use |
This method is deprecated. Use |
This method is deprecated. Use |
Public methods |
|
|---|---|
boolean |
This method is deprecated. Use |
void |
This method is deprecated. Use |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
DEVICE_INFO_REMOTE_EMPTY
public static final DeviceInfo DEVICE_INFO_REMOTE_EMPTY
Same as DEVICE_INFO_REMOTE_EMPTY.
Public constructors
CastPlayer
publicCastPlayer(CastContext castContext)
Creates a new cast player.
The returned player uses a DefaultMediaItemConverter and
mediaItemConverter is set to a DefaultMediaItemConverter,
seekBackIncrementMs is set to DEFAULT_SEEK_BACK_INCREMENT_MS and
seekForwardIncrementMs is set to DEFAULT_SEEK_FORWARD_INCREMENT_MS.
| Parameters | |
|---|---|
CastContext castContext |
The context from which the cast session is obtained. |
CastPlayer
publicCastPlayer(
CastContext castContext,
MediaItemConverter mediaItemConverter
)
Creates a new cast player.
seekBackIncrementMs is set to DEFAULT_SEEK_BACK_INCREMENT_MS and
seekForwardIncrementMs is set to DEFAULT_SEEK_FORWARD_INCREMENT_MS.
| Parameters | |
|---|---|
CastContext castContext |
The context from which the cast session is obtained. |
MediaItemConverter mediaItemConverter |
The |
CastPlayer
publicCastPlayer(
CastContext castContext,
MediaItemConverter mediaItemConverter,
@IntRange(from = 1) long seekBackIncrementMs,
@IntRange(from = 1) long seekForwardIncrementMs
)
Creates a new cast player.
| Parameters | |
|---|---|
CastContext castContext |
The context from which the cast session is obtained. |
MediaItemConverter mediaItemConverter |
The |
@IntRange(from = 1) long seekBackIncrementMs |
The |
@IntRange(from = 1) long seekForwardIncrementMs |
The |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
CastPlayer
publicCastPlayer(
@Nullable Context context,
CastContext castContext,
MediaItemConverter mediaItemConverter,
@IntRange(from = 1) long seekBackIncrementMs,
@IntRange(from = 1) long seekForwardIncrementMs,
@IntRange(from = 0) long maxSeekToPreviousPositionMs
)
Creates a new cast player.
| Parameters | |
|---|---|
@Nullable Context context |
A |
CastContext castContext |
The context from which the cast session is obtained. |
MediaItemConverter mediaItemConverter |
The |
@IntRange(from = 1) long seekBackIncrementMs |
The |
@IntRange(from = 1) long seekForwardIncrementMs |
The |
@IntRange(from = 0) long maxSeekToPreviousPositionMs |
The maximum position for which |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
Public methods
isCastSessionAvailable
public boolean isCastSessionAvailable()Returns whether a cast session is available.
setSessionAvailabilityListener
public voidsetSessionAvailabilityListener(
@Nullable SessionAvailabilityListener listener
)
Sets a listener for updates on the cast session availability.
| Parameters | |
|---|---|
@Nullable SessionAvailabilityListener listener |
The |