MediaPlayerAdapter

public class MediaPlayerAdapter
extends PlayerAdapter

java.lang.Object
   ↳ androidx.leanback.media.PlayerAdapter
     ↳ androidx.leanback.media.MediaPlayerAdapter


This implementation extends the PlayerAdapter with a MediaPlayer.

Summary

Public constructors

MediaPlayerAdapter(Context context)

Constructor.

Public methods

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.

final MediaPlayer getMediaPlayer()

Return the MediaPlayer associated with the MediaPlayerAdapter.

int getProgressUpdatingInterval()

Return updating interval of progress UI in milliseconds.

boolean isPlaying()

Returns true if media is currently playing.

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

Release internal MediaPlayer.

void reset()

Will reset the MediaPlayer and the glue such that a new file can be played.

void seekTo(long positionInMs)

Seek to new position.

boolean setDataSource(Uri uri)

Sets the media source of the player witha given URI.

void setProgressUpdatingEnabled(boolean enable)

Implement this method to enable or disable progress updating.

Protected methods

boolean onError(int what, int extra)

Called to indicate an error.

boolean onInfo(int what, int extra)

Called to indicate an info or a warning.

void onSeekComplete()

Called to indicate the completion of a seek operation.

Inherited methods