Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
Android 0.0.0 Developer Preview
belongs to Maven artifact androidx.leanback:leanback:1.1.0-alpha01
Deprecated since version 0.0.0

MediaControllerGlue

public abstract class MediaControllerGlue
extends PlaybackControlGlue

java.lang.Object
   ↳ androidx.leanback.media.PlaybackGlue
     ↳ androidx.leanback.media.PlaybackControlGlue
       ↳ androidx.leanback.media.MediaControllerGlue


This class was deprecated in API level 0.0.0.
Use MediaControllerAdapter with PlaybackTransportControlGlue or PlaybackBannerControlGlue.

A helper class for implementing a glue layer for MediaControllerCompat.

Summary

Inherited constants

Public constructors

MediaControllerGlue(Context context, int[] fastForwardSpeeds, int[] rewindSpeeds)

Constructor for the glue.

Public methods

void attachToMediaController(MediaControllerCompat mediaController)

Attaches to the given media controller.

void detach()

Detaches from the media controller.

int getCurrentPosition()

Returns the current position of the media item in milliseconds.

int getCurrentSpeedId()

Returns the current playback speed.

Drawable getMediaArt()

Returns a bitmap of the art for the media item.

final MediaControllerCompat getMediaController()

Returns the media controller currently attached.

int getMediaDuration()

Returns the duration of the media item in milliseconds.

CharSequence getMediaSubtitle()

Returns the subtitle of the media item.

CharSequence getMediaTitle()

Returns the title of the media item.

long getSupportedActions()

Returns a bitmask of actions supported by the media player.

boolean hasValidMedia()

Returns true if there is a valid media item.

boolean isMediaPlaying()

Returns true if media is currently playing.

void next()

Goes to the next media item.

void pause()

Pauses the media player.

void play(int speed)

Start playback at the given speed.

void previous()

Goes to the previous media item.

Inherited methods

Public constructors

MediaControllerGlue

public MediaControllerGlue (Context context, 
                int[] fastForwardSpeeds, 
                int[] rewindSpeeds)

Constructor for the glue.

Parameters
fastForwardSpeeds int: Array of seek speeds for fast forward.

rewindSpeeds int: Array of seek speeds for rewind.

Public methods

attachToMediaController

public void attachToMediaController (MediaControllerCompat mediaController)

Attaches to the given media controller.

Parameters
mediaController MediaControllerCompat

detach

public void detach ()

Detaches from the media controller. Must be called when the object is no longer needed.

getCurrentPosition

public int getCurrentPosition ()

Returns the current position of the media item in milliseconds.

Returns
int

getCurrentSpeedId

public int getCurrentSpeedId ()

Returns the current playback speed. When playing normally, PLAYBACK_SPEED_NORMAL should be returned.

Returns
int

getMediaArt

public Drawable getMediaArt ()

Returns a bitmap of the art for the media item.

Returns
Drawable

getMediaController

public final MediaControllerCompat getMediaController ()

Returns the media controller currently attached.

Returns
MediaControllerCompat

getMediaDuration

public int getMediaDuration ()

Returns the duration of the media item in milliseconds.

Returns
int

getMediaSubtitle

public CharSequence getMediaSubtitle ()

Returns the subtitle of the media item.

Returns
CharSequence

getMediaTitle

public CharSequence getMediaTitle ()

Returns the title of the media item.

Returns
CharSequence

getSupportedActions

public long getSupportedActions ()

Returns a bitmask of actions supported by the media player.

Returns
long

hasValidMedia

public boolean hasValidMedia ()

Returns true if there is a valid media item.

Returns
boolean

isMediaPlaying

public boolean isMediaPlaying ()

Returns true if media is currently playing.

Returns
boolean

next

public void next ()

Goes to the next media item. This method is optional.

pause

public void pause ()

Pauses the media player.

play

public void play (int speed)

Start playback at the given speed.

Parameters
speed int: The desired playback speed. For normal playback this will be PlaybackControlGlue.PLAYBACK_SPEED_NORMAL; higher positive values for fast forward, and negative values for rewind.

previous

public void previous ()

Goes to the previous media item. This method is optional.