Most visited

Recently visited

MediaControllerGlue

public abstract class MediaControllerGlue
extends PlaybackControlGlue

java.lang.Object
   ↳ android.support.v17.leanback.app.PlaybackControlGlue
     ↳ android.support.v17.leanback.app.MediaControllerGlue


A helper class for implementing a glue layer between a PlaybackOverlayFragment and a MediaControllerCompat.

Summary

Inherited constants

From class android.support.v17.leanback.app.PlaybackControlGlue

Public constructors

MediaControllerGlue(Context context, PlaybackOverlayFragment fragment, int[] seekSpeeds)

Constructor for the glue.

MediaControllerGlue(Context context, PlaybackOverlayFragment fragment, 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.

Protected methods

void pausePlayback()

Pause playback.

void skipToNext()

Skip to the next track.

void skipToPrevious()

Skip to the previous track.

void startPlayback(int speed)

Start playback at the given speed.

Inherited methods

From class android.support.v17.leanback.app.PlaybackControlGlue
From class java.lang.Object
From interface android.support.v17.leanback.widget.OnActionClickedListener
From interface android.view.View.OnKeyListener

Public constructors

MediaControllerGlue

MediaControllerGlue (Context context, 
                PlaybackOverlayFragment fragment, 
                int[] seekSpeeds)

Constructor for the glue.

The PlaybackOverlayFragment must be passed in. A OnItemViewClickedListener and PlaybackOverlayFragment.InputEventHandler will be set on the fragment.

Parameters
seekSpeeds int: Array of seek speeds for fast forward and rewind.

MediaControllerGlue

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

Constructor for the glue.

The PlaybackOverlayFragment must be passed in. A OnItemViewClickedListener and PlaybackOverlayFragment.InputEventHandler will be set on the fragment.

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

Public methods

attachToMediaController

void attachToMediaController (MediaControllerCompat mediaController)

Attaches to the given media controller.

Parameters
mediaController MediaControllerCompat

detach

void detach ()

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

getCurrentPosition

int getCurrentPosition ()

Returns the current position of the media item in milliseconds.

Returns
int

getCurrentSpeedId

int getCurrentSpeedId ()

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

Returns
int

getMediaArt

Drawable getMediaArt ()

Returns a bitmap of the art for the media item.

Returns
Drawable

getMediaController

MediaControllerCompat getMediaController ()

Returns the media controller currently attached.

Returns
MediaControllerCompat

getMediaDuration

int getMediaDuration ()

Returns the duration of the media item in milliseconds.

Returns
int

getMediaSubtitle

CharSequence getMediaSubtitle ()

Returns the subtitle of the media item.

Returns
CharSequence

getMediaTitle

CharSequence getMediaTitle ()

Returns the title of the media item.

Returns
CharSequence

getSupportedActions

long getSupportedActions ()

Returns a bitmask of actions supported by the media player.

Returns
long

hasValidMedia

boolean hasValidMedia ()

Returns true if there is a valid media item.

Returns
boolean

isMediaPlaying

boolean isMediaPlaying ()

Returns true if media is currently playing.

Returns
boolean

Protected methods

pausePlayback

void pausePlayback ()

Pause playback.

skipToNext

void skipToNext ()

Skip to the next track.

skipToPrevious

void skipToPrevious ()

Skip to the previous track.

startPlayback

void startPlayback (int speed)

Start playback at the given speed.

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

Hooray!