CastPlayer
@UnstableApi
class CastPlayer : 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 |
|---|
class CastPlayer.BuilderBuilder for |
interface CastPlayer.TransferCallbackCallback for moving state across players when transferring playback upon Cast session availability changes. |
Constants |
|
|---|---|
const DeviceInfo! |
Same as |
Public constructors |
|---|
This function is deprecated. Use |
This function is deprecated. Use |
This function is deprecated. Use |
This function is deprecated. Use |
Public functions |
|
|---|---|
Boolean |
This function is deprecated. Use |
Unit |
This function is deprecated. Use |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Constants
DEVICE_INFO_REMOTE_EMPTY
const val DEVICE_INFO_REMOTE_EMPTY: DeviceInfo!
Same as DEVICE_INFO_REMOTE_EMPTY.
Public constructors
CastPlayer
CastPlayer(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
CastPlayer(
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
CastPlayer(
castContext: CastContext!,
mediaItemConverter: MediaItemConverter!,
seekBackIncrementMs: @IntRange(from = 1) Long,
seekForwardIncrementMs: @IntRange(from = 1) Long
)
Creates a new cast player.
| Parameters | |
|---|---|
castContext: CastContext! |
The context from which the cast session is obtained. |
mediaItemConverter: MediaItemConverter! |
The |
seekBackIncrementMs: @IntRange(from = 1) Long |
The |
seekForwardIncrementMs: @IntRange(from = 1) Long |
The |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
CastPlayer
CastPlayer(
context: Context?,
castContext: CastContext!,
mediaItemConverter: MediaItemConverter!,
seekBackIncrementMs: @IntRange(from = 1) Long,
seekForwardIncrementMs: @IntRange(from = 1) Long,
maxSeekToPreviousPositionMs: @IntRange(from = 0) Long
)
Creates a new cast player.
| Parameters | |
|---|---|
context: Context? |
A |
castContext: CastContext! |
The context from which the cast session is obtained. |
mediaItemConverter: MediaItemConverter! |
The |
seekBackIncrementMs: @IntRange(from = 1) Long |
The |
seekForwardIncrementMs: @IntRange(from = 1) Long |
The |
maxSeekToPreviousPositionMs: @IntRange(from = 0) Long |
The maximum position for which |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
If |
Public functions
isCastSessionAvailable
funisCastSessionAvailable(): Boolean
Returns whether a cast session is available.
setSessionAvailabilityListener
funsetSessionAvailabilityListener(listener: SessionAvailabilityListener?): Unit
Sets a listener for updates on the cast session availability.
| Parameters | |
|---|---|
listener: SessionAvailabilityListener? |
The |