Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 27.1.0
belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1

MediaControllerAdapter

public class MediaControllerAdapter
extends PlayerAdapter

java.lang.Object
   ↳ android.support.v17.leanback.media.PlayerAdapter
     ↳ android.support.v17.leanback.media.MediaControllerAdapter


A helper class for implementing a adapter layer for MediaControllerCompat.

Summary

Public constructors

MediaControllerAdapter(MediaControllerCompat controller)

Constructor for the adapter using MediaControllerCompat.

Public methods

void fastForward()

Optional method.

long getBufferedPosition()

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

long getCurrentPosition()

Returns the current position of the media item in milliseconds.

long getDuration()

Returns the duration of the media item in milliseconds.

Drawable getMediaArt(Context context)

Get current media's drawable art.

MediaControllerCompat getMediaController()

Return the object of MediaControllerCompat from this class.

CharSequence getMediaSubtitle()

Get current media's subtitle.

CharSequence getMediaTitle()

Get current media's title.

long getSupportedActions()

Return xor combination of values defined in PlaybackBaseControlGlue.

boolean isPlaying()

Returns true if media is currently playing.

void next()

Optional method.

void onAttachedToHost(PlaybackGlueHost host)

This method is called attached to associated PlaybackGlueHost.

void onDetachedFromHost()

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

void pause()

Pauses the media player.

void play()

Starts the media player.

void previous()

Optional method.

void rewind()

Optional method.

void seekTo(long positionInMs)

Seek to new position.

void setProgressUpdatingEnabled(boolean enabled)

Implement this method to enable or disable progress updating.

void setRepeatAction(int repeatActionIndex)

Optional method.

void setShuffleAction(int shuffleActionIndex)

Optional method.

Inherited methods

From class android.support.v17.leanback.media.PlayerAdapter
From class java.lang.Object

Public constructors

MediaControllerAdapter

added in version 27.1.0
MediaControllerAdapter (MediaControllerCompat controller)

Constructor for the adapter using MediaControllerCompat.

Parameters
controller MediaControllerCompat: Object of MediaControllerCompat..

Public methods

fastForward

added in version 27.1.0
void fastForward ()

Optional method. Override this method if getSupportedActions() include ACTION_FAST_FORWARD to fast forward current media item.

getBufferedPosition

added in version 27.1.0
long getBufferedPosition ()

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

Returns
long

getCurrentPosition

added in version 27.1.0
long getCurrentPosition ()

Returns the current position of the media item in milliseconds.

Returns
long

getDuration

added in version 27.1.0
long getDuration ()

Returns the duration of the media item in milliseconds.

Returns
long

getMediaArt

added in version 27.1.0
Drawable getMediaArt (Context context)

Get current media's drawable art.

Parameters
context Context

Returns
Drawable Drawable art of current media.

getMediaController

added in version 27.1.0
MediaControllerCompat getMediaController ()

Return the object of MediaControllerCompat from this class.

Returns
MediaControllerCompat Media Controller Compat object owned by this class.

getMediaSubtitle

added in version 27.1.0
CharSequence getMediaSubtitle ()

Get current media's subtitle.

Returns
CharSequence Subtitle of current media.

getMediaTitle

added in version 27.1.0
CharSequence getMediaTitle ()

Get current media's title.

Returns
CharSequence Title of current media.

getSupportedActions

added in version 27.1.0
long getSupportedActions ()

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

Returns
long

isPlaying

added in version 27.1.0
boolean isPlaying ()

Returns true if media is currently playing.

Returns
boolean

next

added in version 27.1.0
void next ()

Optional method. Override this method if getSupportedActions() include ACTION_SKIP_TO_NEXT to skip to next item.

onAttachedToHost

added in version 27.1.0
void onAttachedToHost (PlaybackGlueHost host)

This method is called attached to associated PlaybackGlueHost.

onDetachedFromHost

added in version 27.1.0
void onDetachedFromHost ()

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 version 27.1.0
void pause ()

Pauses the media player.

play

added in version 27.1.0
void play ()

Starts the media player.

previous

added in version 27.1.0
void previous ()

Optional method. Override this method if getSupportedActions() include ACTION_SKIP_TO_PREVIOUS to skip to previous item.

rewind

added in version 27.1.0
void rewind ()

Optional method. Override this method if getSupportedActions() include ACTION_REWIND to rewind in current media item.

seekTo

added in version 27.1.0
void seekTo (long positionInMs)

Seek to new position.

Parameters
positionInMs long: New position in milliseconds.

setProgressUpdatingEnabled

added in version 27.1.0
void setProgressUpdatingEnabled (boolean enabled)

Implement this method to enable or disable progress updating.

Parameters
enabled boolean: True to enable progress updating, false otherwise.

setRepeatAction

added in version 27.1.0
void setRepeatAction (int repeatActionIndex)

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_ONE INDEX_ALL, INDEX_NONE,

setShuffleAction

added in version 27.1.0
void setShuffleAction (int shuffleActionIndex)

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_OFF INDEX_ON