public abstract class PlayerAdapter
extends Object


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 MediaPlayer. ExoPlayer also provides a leanback extension that implements PlayerAdapter. Please see ExoPlayer


Nested classes

class PlayerAdapter.Callback

Client for client of PlayerAdapter. 

Public constructors


Public methods

void fastForward()

Optional method.

long getBufferedPosition()

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

final PlayerAdapter.Callback getCallback()

Gets callback for event of PlayerAdapter.

long getCurrentPosition()

Returns the current position of the media item in milliseconds.

long getDuration()

Returns the duration of the media item in milliseconds.

long getSupportedActions()

Return xor combination of values defined in PlaybackBaseControlGlue.

boolean isPlaying()

Returns true if media is currently playing.

boolean isPrepared()
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.

abstract void pause()

Pauses the media player.

abstract void play()

Starts the media player.

void previous()

Optional method.

void rewind()

Optional method.

void seekTo(long positionInMs)

Seek to new position.

final void setCallback(PlayerAdapter.Callback callback)

Sets callback for event of PlayerAdapter.

void setProgressUpdatingEnabled(boolean enable)

Implement this method to enable or disable progress updating.

void setRepeatAction(int repeatActionIndex)

Optional method.

void setShuffleAction(int shuffleActionIndex)

Optional method.

Inherited methods

Public constructors


public PlayerAdapter ()

Public methods


public void fastForward ()

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


public long getBufferedPosition ()

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



public final