MediaControllerAdapter


class MediaControllerAdapter : PlayerAdapter


A helper class for implementing a adapter layer for MediaControllerCompat.

Summary

Public constructors

Constructor for the adapter using MediaControllerCompat.

Public functions

Unit

Optional method.

Long

Returns the current buffered position of the media item in milliseconds.

Long

Returns the current position of the media item in milliseconds.

Long

Returns the duration of the media item in milliseconds.

Drawable!
getMediaArt(context: Context!)

Get current media's drawable art.

MediaControllerCompat!

Return the object of MediaControllerCompat from this class.

CharSequence!

Get current media's subtitle.

CharSequence!

Get current media's title.

Long

Return xor combination of values defined in PlaybackBaseControlGlue.

Boolean

Returns true if media is currently playing.

Unit

Optional method.

Unit

This method is called attached to associated PlaybackGlueHost.

Unit

This method is called when current associated PlaybackGlueHost is attached to a different PlaybackGlue or PlaybackGlueHost is destroyed.

Unit

Pauses the media player.

Unit

Starts the media player.

Unit

Optional method.

Unit

Optional method.

Unit
seekTo(positionInMs: Long)

Seek to new position.

Unit

Implement this method to enable or disable progress updating.

Unit
setRepeatAction(repeatActionIndex: Int)

Optional method.

Unit
setShuffleAction(shuffleActionIndex: Int)

Optional method.

Inherited functions

From androidx.leanback.media.PlayerAdapter
PlayerAdapter.Callback?

Gets callback for event of PlayerAdapter.

Boolean
Unit

Sets callback for event of PlayerAdapter.

Public constructors

MediaControllerAdapter

Added in 1.1.0
MediaControllerAdapter(controller: MediaControllerCompat!)

Constructor for the adapter using MediaControllerCompat.

Parameters
controller: MediaControllerCompat!

Object of MediaControllerCompat..

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.

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.

getMediaArt

Added in 1.1.0
fun getMediaArt(context: Context!): Drawable!

Get current media's drawable art.

Returns
Drawable!

Drawable art of current media.

getMediaController

Added in 1.1.0
fun getMediaController(): MediaControllerCompat!

Return the object of MediaControllerCompat from this class.

Returns
MediaControllerCompat!

Media Controller Compat object owned by this class.

getMediaSubtitle

Added in 1.1.0
fun getMediaSubtitle(): CharSequence!

Get current media's subtitle.

Returns
CharSequence!

Subtitle of current media.

getMediaTitle

Added in 1.1.0
fun getMediaTitle(): CharSequence!

Get current media's title.

Returns
CharSequence!

Title of current media.

getSupportedActions

fun getSupportedActions(): Long

Return xor combination of values defined in PlaybackBaseControlGlue. Default is PLAY_PAUSE (unless subclass enforce to be 0)

isPlaying

fun isPlaying(): Boolean

Returns true if media is currently playing.

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.

pause

Added in 1.2.0-alpha04
fun pause(): Unit

Pauses the media player.

play

Added in 1.2.0-alpha04
fun play(): Unit

Starts the media player.

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.

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: INDEX_ONEINDEX_ALL, INDEX_NONE,

setShuffleAction

fun setShuffleAction(shuffleActionIndex: Int): Unit

Optional method. Override this method if getSupportedActions include ACTION_SHUFFLE to set the shuffle action.

Parameters
shuffleActionIndex: Int

The repeat action. Must be one of the followings: INDEX_OFFINDEX_ON