PlaybackTransportControlGlue

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

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 in that manages interaction between the leanback UI components PlaybackControlsRowPlaybackTransportRowPresenter and a functional PlayerAdapter which represents the underlying media player.

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

The glue has two actions bar: primary actions bar and secondary actions bar. App can provide additional actions by overriding onCreatePrimaryActions and / or onCreateSecondaryActions and respond to actions by override onActionClicked(Action).

It's also subclass's responsibility to implement the "repeat mode" in onPlayCompleted().

Apps calls setSeekProvider(PlaybackSeekDataProvider) to provide seek data. If the PlaybackGlueHost is instance of PlaybackSeekUi, the provider will be passed to PlaybackGlueHost to render thumb bitmaps.

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

Inherited constants

Public constructors

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

Constructor for the glue.

Public methods

PlaybackSeekDataProvider!

Get seek data provider used during user seeking.

Boolean

open Unit

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

open Unit

Unit
setSeekEnabled(seekEnabled: Boolean)

Enable or disable seek when getSeekProvider() is null.

Unit

Set seek data provider used during user seeking.

Protected methods

open Unit

open Unit
onCreatePrimaryActions(primaryActionsAdapter: ArrayObjectAdapter!)

open PlaybackRowPresenter!

open Unit

open Unit

open Unit

Inherited functions

Public constructors

<init>

PlaybackTransportControlGlue(context: Context!, impl: T)

Constructor for the glue.

Parameters
context Context!:
impl Context!: Implementation to underlying media player.

Public methods

getSeekProvider

fun getSeekProvider(): PlaybackSeekDataProvider!

Get seek data provider used during user seeking.

Return
PlaybackSeekDataProvider!: Seek data provider used during user seeking.

isSeekEnabled

fun isSeekEnabled(): Boolean
Return
Boolean: True if seek is enabled without PlaybackSeekDataProvider, false otherwise.

onActionClicked

open fun onActionClicked(action: Action!): Unit

onKey

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

setControlsRow

open fun setControlsRow(controlsRow: PlaybackControlsRow!): Unit

setSeekEnabled

fun setSeekEnabled(seekEnabled: Boolean): Unit

Enable or disable seek when getSeekProvider() is null. When true, PlayerAdapter#seekTo(long) will be called during user seeking.

Parameters
seekEnabled Boolean: True to enable seek, false otherwise

setSeekProvider

fun setSeekProvider(seekProvider: PlaybackSeekDataProvider!): Unit

Set seek data provider used during user seeking.

Parameters
seekProvider PlaybackSeekDataProvider!: Seek data provider used during user seeking.

Protected methods

onAttachedToHost

protected open fun onAttachedToHost(host: PlaybackGlueHost!): Unit

onCreatePrimaryActions

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

onCreateRowPresenter

protected open fun onCreateRowPresenter(): PlaybackRowPresenter!

onDetachedFromHost

protected open fun onDetachedFromHost(): Unit

onPlayStateChanged

protected open fun onPlayStateChanged(): Unit

onUpdateProgress

protected open fun onUpdateProgress(): Unit