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:
 public class MyVideoFragment extends VideoFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PlaybackTransportControlGlue 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(); } } 

Summary

Inherited constants
Public constructors
<init>(context: Context!, impl: T)

Constructor for the glue.

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

Unit

Set seek data provider used during user seeking.

Boolean

open Unit

open Unit

Unit
setSeekEnabled(seekEnabled: Boolean)

Enable or disable seek when getSeekProvider() is null.

PlaybackSeekDataProvider!

Get seek data provider used during user seeking.

Protected methods
open Unit
onCreatePrimaryActions(primaryActionsAdapter: ArrayObjectAdapter!)

open Unit

open Unit

open Unit

open PlaybackRowPresenter!

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

onKey

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

setSeekProvider

fun setSeekProvider(seekProvider: PlaybackSeekDataProvider!): Unit

Set seek data provider used during user seeking.

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

isSeekEnabled

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

setControlsRow

open fun setControlsRow(controlsRow: PlaybackControlsRow!): Unit

onActionClicked

open fun onActionClicked(action: Action!): 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

getSeekProvider

fun getSeekProvider(): PlaybackSeekDataProvider!

Get seek data provider used during user seeking.

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

Protected methods

onCreatePrimaryActions

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

onDetachedFromHost

protected open fun onDetachedFromHost(): Unit

onPlayStateChanged

protected open fun onPlayStateChanged(): Unit

onUpdateProgress

protected open fun onUpdateProgress(): Unit

onCreateRowPresenter

protected open fun onCreateRowPresenter(): PlaybackRowPresenter!

onAttachedToHost

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