PlaybackBannerControlGlue

public class PlaybackBannerControlGlue
extends PlaybackBaseControlGlue<T extends PlayerAdapter>

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


A helper 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 PlaybackControlsRowPresenter and a functional PlayerAdapter which represents the underlying media player.

Apps must pass a PlayerAdapter in the 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 PlaybackBaseControlGlue.onCreateSecondaryActions(ArrayObjectAdapter) and respond to actions by overriding onActionClicked(Action).

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

Sample Code:

 public class MyVideoFragment extends VideoFragment {
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         PlaybackBannerControlGlue playerGlue =
                 new PlaybackBannerControlGlue(getActivity(),
                         new MediaPlayerAdapter(getActivity()));
         playerGlue.setHost(new VideoFragmentGlueHost(this));
         playerGlue.setSubtitle("Leanback artist");
         playerGlue.setTitle("Leanback team at work");
         String uriPath = "android.resource://com.example.android.leanback/raw/video";
         playerGlue.getPlayerAdapter().setDataSource(Uri.parse(uriPath));
         playerGlue.playWhenPrepared();
     }
 }
 

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_REWIND

The adapter key for the rewind 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.

int PLAYBACK_SPEED_FAST_L0

The initial (level 0) fast forward playback speed.

int PLAYBACK_SPEED_FAST_L1

The level 1 fast forward playback speed.

int PLAYBACK_SPEED_FAST_L2

The level 2 fast forward playback speed.

int PLAYBACK_SPEED_FAST_L3

The level 3 fast forward playback speed.

int PLAYBACK_SPEED_FAST_L4

The level 4 fast forward playback speed.

int PLAYBACK_SPEED_INVALID

Invalid playback speed.

int PLAYBACK_SPEED_NORMAL

Speed representing playback state that is playing normally.

int PLAYBACK_SPEED_PAUSED

Speed representing playback state that is paused.

Inherited constants

Public constructors

PlaybackBannerControlGlue(Context context, int[] seekSpeeds, T impl)

Constructor for the glue.

PlaybackBannerControlGlue(Context context, int[] fastForwardSpeeds, int[] rewindSpeeds, T impl)

Constructor for the glue.

Public methods

long getCurrentPosition()

Gets current position of the player.

int[] getFastForwardSpeeds()

Returns the fast forward speeds.

int[] getRewindSpeeds()

Returns the rewind speeds.

void onActionClicked(Action action)

Handles action clicks.