PlayerAdapter
abstract class PlayerAdapter
kotlin.Any | |
↳ | androidx.leanback.media.PlayerAdapter |
Base class that wraps underlying media player. The class is used by PlaybackGlue, for example PlaybackTransportControlGlue
is bound to a PlayerAdapter. This class is intended to be subclassed, MediaPlayerAdapter
is a concrete subclass using android.media.MediaPlayer
. ExoPlayer also provides a leanback extension that implements PlayerAdapter. Please see ExoPlayer https://developer.android.com/guide/topics/media/exoplayer
Summary
Nested classes | |
---|---|
open |
Client for client of PlayerAdapter. |
Public constructors | |
---|---|
<init>() Base class that wraps underlying media player. |
Public methods | |
---|---|
open Unit |
Optional method. |
open Long |
Returns the current buffered position of the media item in milliseconds. |
PlayerAdapter.Callback! |
Gets callback for event of PlayerAdapter. |
open Long |
Returns the current position of the media item in milliseconds. |
open Long |
Returns the duration of the media item in milliseconds. |
open Long |
Return xor combination of values defined in PlaybackBaseControlGlue. |
open Boolean |
Returns true if media is currently playing. |
open Boolean | |
open Unit |
next() Optional method. |
open Unit |
onAttachedToHost(host: PlaybackGlueHost!) This method is called attached to associated |
open Unit |
This method is called when current associated |
abstract Unit |
pause() Pauses the media player. |
abstract Unit |
play() Starts the media player. |
open Unit |
previous() Optional method. |
open Unit |
rewind() Optional method. |
open Unit |
Seek to new position. |
Unit |
setCallback(callback: PlayerAdapter.Callback!) Sets callback for event of PlayerAdapter. |
open Unit |
setProgressUpdatingEnabled(enable: Boolean) Implement this method to enable or disable progress updating. |
open Unit |
setRepeatAction(repeatActionIndex: Int) Optional method. |
open Unit |
setShuffleAction(shuffleActionIndex: Int) Optional method. |
Public constructors
<init>
PlayerAdapter()
Base class that wraps underlying media player. The class is used by PlaybackGlue, for example PlaybackTransportControlGlue
is bound to a PlayerAdapter. This class is intended to be subclassed, MediaPlayerAdapter
is a concrete subclass using android.media.MediaPlayer
. ExoPlayer also provides a leanback extension that implements PlayerAdapter. Please see ExoPlayer https://developer.android.com/guide/topics/media/exoplayer
Public methods
fastForward
open fun fastForward(): Unit
Optional method. Override this method if getSupportedActions()
include PlaybackBaseControlGlue#ACTION_FAST_FORWARD
to fast forward current media item.
getBufferedPosition
open fun getBufferedPosition(): Long
Returns the current buffered position of the media item in milliseconds.
getCallback
fun getCallback(): PlayerAdapter.Callback!
Gets callback for event of PlayerAdapter.
Return | |
---|---|
PlayerAdapter.Callback! |
Client for event of PlayerAdapter. |
getCurrentPosition
open fun getCurrentPosition(): Long
Returns the current position of the media item in milliseconds.
getSupportedActions
open fun getSupportedActions(): Long
Return xor combination of values defined in PlaybackBaseControlGlue. Default is PLAY_PAUSE (unless subclass enforce to be 0)
isPrepared
open fun isPrepared(): Boolean
Return | |
---|---|
Boolean |
True if media is ready for playback, false otherwise. |
next
open fun next(): Unit
Optional method. Override this method if getSupportedActions()
include PlaybackBaseControlGlue#ACTION_SKIP_TO_NEXT
to skip to next item.
onAttachedToHost
open fun onAttachedToHost(host: PlaybackGlueHost!): Unit
This method is called attached to associated PlaybackGlueHost
.
Parameters | |
---|---|
host |
PlaybackGlueHost!: |
onDetachedFromHost
open fun onDetachedFromHost(): Unit
This method is called when current associated PlaybackGlueHost
is attached to a different PlaybackGlue
or PlaybackGlueHost
is destroyed. Subclass may override. A typical implementation will release resources (e.g. MediaPlayer or connection to playback service) in this method.
previous
open fun previous(): Unit
Optional method. Override this method if getSupportedActions()
include PlaybackBaseControlGlue#ACTION_SKIP_TO_PREVIOUS
to skip to previous item.
rewind
open fun rewind(): Unit
Optional method. Override this method if getSupportedActions()
include PlaybackBaseControlGlue#ACTION_REWIND
to rewind in current media item.
seekTo
open fun seekTo(positionInMs: Long): Unit
Seek to new position.
Parameters | |
---|---|
positionInMs |
Long: New position in milliseconds. |
setCallback
fun setCallback(callback: PlayerAdapter.Callback!): Unit
Sets callback for event of PlayerAdapter.
Parameters | |
---|---|
callback |
PlayerAdapter.Callback!: Client for event of PlayerAdapter. |
setProgressUpdatingEnabled
open fun setProgressUpdatingEnabled(enable: Boolean): Unit
Implement this method to enable or disable progress updating.
Parameters | |
---|---|
enable |
Boolean: True to enable progress updating, false otherwise. |
setRepeatAction
open fun setRepeatAction(repeatActionIndex: Int): Unit
Optional method. Override this method if getSupportedActions()
include PlaybackBaseControlGlue#ACTION_REPEAT
to set the repeat action.
Parameters | |
---|---|
repeatActionIndex |
Int: The shuffle action. Must be one of the followings: androidx.leanback.widget.PlaybackControlsRow.RepeatAction#INDEX_ONE androidx.leanback.widget.PlaybackControlsRow.RepeatAction#INDEX_ALL , androidx.leanback.widget.PlaybackControlsRow.RepeatAction#INDEX_NONE , |
setShuffleAction
open fun setShuffleAction(shuffleActionIndex: Int): Unit
Optional method. Override this method if getSupportedActions()
include PlaybackBaseControlGlue#ACTION_SHUFFLE
to set the shuffle action.
Parameters | |
---|---|
shuffleActionIndex |
Int: The repeat action. Must be one of the followings: androidx.leanback.widget.PlaybackControlsRow.ShuffleAction#INDEX_OFF androidx.leanback.widget.PlaybackControlsRow.ShuffleAction#INDEX_ON |