PlaybackBaseControlGlue

public abstract class PlaybackBaseControlGlue
extends PlaybackGlue implements OnActionClickedListener, View.OnKeyListener

java.lang.Object
   ↳ androidx.leanback.media.PlaybackGlue
     ↳ androidx.leanback.media.PlaybackBaseControlGlue<T extends androidx.leanback.media.PlayerAdapter>


A base abstract class for managing a PlaybackControlsRow being displayed in PlaybackGlueHost. It supports standard playback control actions play/pause and skip next/previous. This helper class is a glue layer that manages interaction between the leanback UI components PlaybackControlsRow PlaybackRowPresenter and a functional PlayerAdapter which represents the underlying media player.

The app must pass a PlayerAdapter in constructor for a specific implementation e.g. a MediaPlayerAdapter.

The glue has two action bars: primary action bars and secondary action bars. Apps can provide additional actions by overriding onCreatePrimaryActions(ArrayObjectAdapter) and / or onCreateSecondaryActions(ArrayObjectAdapter) and respond to actions by overriding onActionClicked(Action).

The subclass is responsible for implementing the "repeat mode" in onPlayCompleted().

Summary

Constants

int ACTION_CUSTOM_LEFT_FIRST

The adapter key for the first custom control on the left side of the predefined primary controls.

int ACTION_CUSTOM_RIGHT_FIRST

The adapter key for the first custom control on the right side of the predefined primary controls.

int ACTION_FAST_FORWARD

The adapter key for the fast forward control.

int ACTION_PLAY_PAUSE

The adapter key for the play/pause control.

int ACTION_REPEAT

The adapter key for the repeat control.

int ACTION_REWIND

The adapter key for the rewind control.

int ACTION_SHUFFLE

The adapter key for the shuffle control.

int ACTION_SKIP_TO_NEXT

The adapter key for the skip to next control.

int ACTION_SKIP_TO_PREVIOUS

The adapter key for the skip to previous control.

Public constructors

PlaybackBaseControlGlue(Context context, T impl)

Constructor for the glue.

Public methods

Drawable getArt()
final long getBufferedPosition()
PlaybackControlsRow getControlsRow()

Returns the playback controls row managed by the glue layer.

long getCurrentPosition()
final long getDuration()
PlaybackRowPresenter getPlaybackRowPresenter()

Returns the playback controls row Presenter managed by the glue layer.

final T getPlayerAdapter()
CharSequence getSubtitle()

Return The media subtitle.

long getSupportedActions()

Returns a bitmask of actions supported by the media player.

CharSequence getTitle()

Returns the title of the media item.

boolean isControlsOverlayAutoHideEnabled()

Returns true if the controls auto hides after a timeout when media is playing.

final boolean isPlaying()

Returns true if media is currently playing.

final boolean isPrepared()

Returns true when the media player is prepared to start media playback.

void next()

Goes to the next media item.

abstract void onActionClicked(Action action)

Handles action clicks.

abstract boolean onKey(View v, int keyCode, KeyEvent event)

Handles key events and returns true if handled.

void pause()

Pauses the media player.

void play()

Starts the media player.