PlayerAdapter
abstract class PlayerAdapter
LeanbackPlayerAdapter |
Leanback |
MediaControllerAdapter |
A helper class for implementing a adapter layer for |
MediaPlayerAdapter |
This implementation extends the |
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 types |
|---|
class PlayerAdapter.CallbackClient for client of PlayerAdapter. |
Public constructors |
|---|
Public functions |
|
|---|---|
Unit |
Optional method. |
Long |
Returns the current buffered position of the media item in milliseconds. |
PlayerAdapter.Callback? |
Gets callback for event of PlayerAdapter. |
Long |
Returns the current position of the media item in milliseconds. |
Long |
Returns the duration of the media item in milliseconds. |
Long |
Return xor combination of values defined in PlaybackBaseControlGlue. |
Boolean |
Returns true if media is currently playing. |
Boolean |
|
Unit |
next()Optional method. |
Unit |
onAttachedToHost(host: PlaybackGlueHost)This method is called attached to associated |
Unit |
This method is called when current associated |
abstract Unit |
pause()Pauses the media player. |
abstract Unit |
play()Starts the media player. |
Unit |
previous()Optional method. |
Unit |
rewind()Optional method. |
Unit |
Seek to new position. |
Unit |
setCallback(callback: PlayerAdapter.Callback?)Sets callback for event of PlayerAdapter. |
Unit |
setProgressUpdatingEnabled(enable: Boolean)Implement this method to enable or disable progress updating. |
Unit |
setRepeatAction(repeatActionIndex: Int)Optional method. |
Unit |
setShuffleAction(shuffleActionIndex: Int)Optional method. |
Public constructors
Public functions
fastForward
fun fastForward(): Unit
Optional method. Override this method if getSupportedActions include ACTION_FAST_FORWARD to fast forward current media item.
getBufferedPosition
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.
| Returns | |
|---|---|
PlayerAdapter.Callback? |
Client for event of PlayerAdapter. |
getCurrentPosition
fun getCurrentPosition(): Long
Returns the current position of the media item in milliseconds.
getDuration
fun getDuration(): Long
Returns the duration of the media item in milliseconds.
getSupportedActions
fun getSupportedActions(): Long
Return xor combination of values defined in PlaybackBaseControlGlue. Default is PLAY_PAUSE (unless subclass enforce to be 0)
isPrepared
fun isPrepared(): Boolean
| Returns | |
|---|---|
Boolean |
True if media is ready for playback, false otherwise. |
next
fun next(): Unit
Optional method. Override this method if getSupportedActions include ACTION_SKIP_TO_NEXT to skip to next item.
onAttachedToHost
fun onAttachedToHost(host: PlaybackGlueHost): Unit
This method is called attached to associated PlaybackGlueHost.
| Parameters | |
|---|---|
host: PlaybackGlueHost |
onDetachedFromHost
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
fun previous(): Unit
Optional method. Override this method if getSupportedActions include ACTION_SKIP_TO_PREVIOUS to skip to previous item.
rewind
fun rewind(): Unit
Optional method. Override this method if getSupportedActions include ACTION_REWIND to rewind in current media item.
seekTo
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
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
fun setRepeatAction(repeatActionIndex: Int): Unit
Optional method. Override this method if getSupportedActions include ACTION_REPEAT to set the repeat action.
| Parameters | |
|---|---|
repeatActionIndex: Int |
The shuffle action. Must be one of the followings: |
setShuffleAction
fun setShuffleAction(shuffleActionIndex: Int): Unit
Optional method. Override this method if getSupportedActions include ACTION_SHUFFLE to set the shuffle action.