PlaybackBannerControlGlue

open class PlaybackBannerControlGlue<T : PlayerAdapter!> : PlaybackBaseControlGlue<T>
kotlin.Any
   ↳ androidx.leanback.media.PlaybackGlue
   ↳ androidx.leanback.media.PlaybackBaseControlGlue<T>
   ↳ androidx.leanback.media.PlaybackBannerControlGlue

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 PlaybackControlsRowPlaybackControlsRowPresenter 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 and / or onCreateSecondaryActions and respond to actions by overriding onActionClicked(Action).

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

Sample Code:
<code>
  public class MyVideoFragment extends VideoFragment {
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          PlaybackBannerControlGlue
 <mediaplayeradapter>
   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(); } } 
 </mediaplayeradapter></code>

Summary

Constants

static Int

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

static Int

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

static Int

The adapter key for the fast forward control.

static Int

The adapter key for the play/pause control.

static Int

The adapter key for the rewind control.

static Int

The adapter key for the skip to next control.

static Int

The adapter key for the skip to previous control.

static Int

The initial (level 0) fast forward playback speed.

static Int

The level 1 fast forward playback speed.

static Int

The level 2 fast forward playback speed.

static Int

The level 3 fast forward playback speed.

static Int

The level 4 fast forward playback speed.

static Int

Invalid playback speed.

static Int

Speed representing playback state that is playing normally.

static Int

Speed representing playback state that is paused.

Inherited constants

Public constructors

<init>(context: Context!, seekSpeeds: IntArray!, impl: T)

Constructor for the glue.

<init>(context: Context!, fastForwardSpeeds: IntArray!, rewindSpeeds: IntArray!, impl: T)

Constructor for the glue.

Public methods

open Long

Gets current position of the player.

open IntArray

Returns the fast forward speeds.

open IntArray

Returns the rewind speeds.

open Unit

Handles action clicks.

open Boolean
onKey(v: View!, keyCode: Int, event: KeyEvent!)

Handles key events and returns true if handled.

open Unit

open Unit

open Unit

Protected methods

open Unit
onCreatePrimaryActions(primaryActionsAdapter: ArrayObjectAdapter!)

open PlaybackRowPresenter!

open Unit

open Unit

Inherited functions

Constants

ACTION_CUSTOM_LEFT_FIRST

static val ACTION_CUSTOM_LEFT_FIRST: Int

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

Value: PlaybackBaseControlGlue.ACTION_CUSTOM_LEFT_FIRST

ACTION_CUSTOM_RIGHT_FIRST

static val ACTION_CUSTOM_RIGHT_FIRST: Int

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

Value: PlaybackBaseControlGlue.ACTION_CUSTOM_RIGHT_FIRST

ACTION_FAST_FORWARD

static val ACTION_FAST_FORWARD: Int

The adapter key for the fast forward control.

Value: PlaybackBaseControlGlue.ACTION_FAST_FORWARD

ACTION_PLAY_PAUSE

static val ACTION_PLAY_PAUSE: Int

The adapter key for the play/pause control.

Value: PlaybackBaseControlGlue.ACTION_PLAY_PAUSE

ACTION_REWIND

static val ACTION_REWIND: Int

The adapter key for the rewind control.

Value: PlaybackBaseControlGlue.ACTION_REWIND

ACTION_SKIP_TO_NEXT

static val ACTION_SKIP_TO_NEXT: Int

The adapter key for the skip to next control.

Value: PlaybackBaseControlGlue.ACTION_SKIP_TO_NEXT

ACTION_SKIP_TO_PREVIOUS

static val ACTION_SKIP_TO_PREVIOUS: Int

The adapter key for the skip to previous control.

Value: PlaybackBaseControlGlue.ACTION_SKIP_TO_PREVIOUS

PLAYBACK_SPEED_FAST_L0

static val PLAYBACK_SPEED_FAST_L0: Int

The initial (level 0) fast forward playback speed. The negative of this value is for rewind at the same speed.

Value: 10

PLAYBACK_SPEED_FAST_L1

static val PLAYBACK_SPEED_FAST_L1: Int

The level 1 fast forward playback speed. The negative of this value is for rewind at the same speed.

Value: 11

PLAYBACK_SPEED_FAST_L2

static val PLAYBACK_SPEED_FAST_L2: Int

The level 2 fast forward playback speed. The negative of this value is for rewind at the same speed.

Value: 12

PLAYBACK_SPEED_FAST_L3

static val PLAYBACK_SPEED_FAST_L3: Int

The level 3 fast forward playback speed. The negative of this value is for rewind at the same speed.

Value: 13

PLAYBACK_SPEED_FAST_L4

static val PLAYBACK_SPEED_FAST_L4: Int

The level 4 fast forward playback speed. The negative of this value is for rewind at the same speed.

Value: 14

PLAYBACK_SPEED_INVALID

static val PLAYBACK_SPEED_INVALID: Int

Invalid playback speed.

Value: -1

PLAYBACK_SPEED_NORMAL

static val PLAYBACK_SPEED_NORMAL: Int

Speed representing playback state that is playing normally.

Value: 1

PLAYBACK_SPEED_PAUSED

static val PLAYBACK_SPEED_PAUSED: Int

Speed representing playback state that is paused.

Value: 0

Public constructors

<init>

PlaybackBannerControlGlue(context: Context!, seekSpeeds: IntArray!, impl: T)

Constructor for the glue.

Parameters
context Context!:
seekSpeeds Context!: The array of seek speeds for fast forward and rewind. The maximum length of the array is defined as NUMBER_OF_SEEK_SPEEDS.
impl Context!: Implementation to underlying media player.

<init>

PlaybackBannerControlGlue(context: Context!, fastForwardSpeeds: IntArray!, rewindSpeeds: IntArray!, impl: T)

Constructor for the glue.

Parameters
context Context!:
fastForwardSpeeds Context!: The array of seek speeds for fast forward. The maximum length of the array is defined as NUMBER_OF_SEEK_SPEEDS.
rewindSpeeds Context!: The array of seek speeds for rewind. The maximum length of the array is defined as NUMBER_OF_SEEK_SPEEDS.
impl Context!: Implementation to underlying media player.

Public methods

getCurrentPosition

open fun getCurrentPosition(): Long

Gets current position of the player. If the player is playing/paused, this method returns current position from PlayerAdapter. Otherwise, if the player is fastforwarding/rewinding, the method fake-pauses the PlayerAdapter and returns its own calculated position.

Return
Long: Current position of the player.

getFastForwardSpeeds

@NonNull open fun getFastForwardSpeeds(): IntArray

Returns the fast forward speeds.

getRewindSpeeds

@NonNull open fun getRewindSpeeds(): IntArray

Returns the rewind speeds.

onActionClicked

open fun onActionClicked(action: Action!): Unit

Handles action clicks. A subclass may override this add support for additional actions.

onKey

open fun onKey(v: View!, keyCode: Int, event: KeyEvent!): Boolean

Handles key events and returns true if handled. A subclass may override this to provide additional support.

pause

open fun pause(): Unit

play

open fun play(): Unit

setControlsRow

open fun setControlsRow(controlsRow: PlaybackControlsRow!): Unit

Protected methods

onCreatePrimaryActions

protected open fun onCreatePrimaryActions(primaryActionsAdapter: ArrayObjectAdapter!): Unit

onCreateRowPresenter

protected open fun onCreateRowPresenter(): PlaybackRowPresenter!

onPlayCompleted

protected open fun onPlayCompleted(): Unit

onPlayStateChanged

protected open fun onPlayStateChanged(): Unit