belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
PlaybackTransportControlGlue
public
class
PlaybackTransportControlGlue
extends PlaybackBaseControlGlue<T extends PlayerAdapter>
java.lang.Object | |||
↳ | android.support.v17.leanback.media.PlaybackGlue | ||
↳ | android.support.v17.leanback.media.PlaybackBaseControlGlue<T extends android.support.v17.leanback.media.PlayerAdapter> | ||
↳ | android.support.v17.leanback.media.PlaybackTransportControlGlue<T extends android.support.v17.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 in that manages interaction between the
leanback UI components PlaybackControlsRow
PlaybackTransportRowPresenter
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(ArrayObjectAdapter)
and / or
onCreateSecondaryActions(ArrayObjectAdapter)
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.
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 |
---|
From
class
android.support.v17.leanback.media.PlaybackBaseControlGlue
|
Public constructors | |
---|---|
PlaybackTransportControlGlue(Context context, T impl)
Constructor for the glue. |
Public methods | |
---|---|
final
PlaybackSeekDataProvider
|
getSeekProvider()
Get seek data provider used during user seeking. |
final
boolean
|
isSeekEnabled()
|
void
|
onActionClicked(Action action)
Handles action clicks. |
boolean
|
onKey(View v, int keyCode, KeyEvent event)
Handles key events and returns true if handled. |
void
|
setControlsRow(PlaybackControlsRow controlsRow)
Sets the controls row to be managed by the glue layer. |
final
void
|
setSeekEnabled(boolean seekEnabled)
Enable or disable seek when |
final
void
|
setSeekProvider(PlaybackSeekDataProvider seekProvider)
Set seek data provider used during user seeking. |
Protected methods | |
---|---|
void
|
onAttachedToHost(PlaybackGlueHost host)
This method is called attached to associated |
void
|
onCreatePrimaryActions(ArrayObjectAdapter primaryActionsAdapter)
May be overridden to add primary actions to the adapter. |
PlaybackRowPresenter
|
onCreateRowPresenter()
|
void
|
onDetachedFromHost()
This method is called when current associated |
void
|
onPlayStateChanged()
Event when play state changed. |
void
|
onUpdateProgress()
|
Inherited methods | |
---|---|
From
class
android.support.v17.leanback.media.PlaybackBaseControlGlue
| |
From
class
android.support.v17.leanback.media.PlaybackGlue
| |
From
class
java.lang.Object
| |
From
interface
android.support.v17.leanback.widget.OnActionClickedListener
| |
From
interface
android.view.View.OnKeyListener
|
Public constructors
PlaybackTransportControlGlue
PlaybackTransportControlGlue (Context context, T impl)
Constructor for the glue.
Parameters | |
---|---|
impl |
T : Implementation to underlying media player.
|
Public methods
getSeekProvider
PlaybackSeekDataProvider getSeekProvider ()
Get seek data provider used during user seeking.
Returns | |
---|---|
PlaybackSeekDataProvider |
Seek data provider used during user seeking. |
isSeekEnabled
boolean isSeekEnabled ()
Returns | |
---|---|
boolean |
True if seek is enabled without PlaybackSeekDataProvider , false otherwise.
|
onActionClicked
void onActionClicked (Action action)
Handles action clicks. A subclass may override this add support for additional actions.
Parameters | |
---|---|
action |
Action |
onKey
boolean onKey (View v, int keyCode, KeyEvent event)
Handles key events and returns true if handled. A subclass may override this to provide additional support.
Parameters | |
---|---|
v |
View |
keyCode |
int |
event |
KeyEvent |
Returns | |
---|---|
boolean |
setControlsRow
void setControlsRow (PlaybackControlsRow controlsRow)
Sets the controls row to be managed by the glue layer. If
getPrimaryActionsAdapter()
is not provided, a default
ArrayObjectAdapter
will be created and initialized in
onCreatePrimaryActions(ArrayObjectAdapter)
. If
getSecondaryActionsAdapter()
is not provided, a default
ArrayObjectAdapter
will be created and initialized in
onCreateSecondaryActions(ArrayObjectAdapter)
.
The primary actions and playback state related aspects of the row
are updated by the glue.
Parameters | |
---|---|
controlsRow |
PlaybackControlsRow |
setSeekEnabled
void setSeekEnabled (boolean seekEnabled)
Enable or disable seek when getSeekProvider()
is null. When true,
seekTo(long)
will be called during user seeking.
Parameters | |
---|---|
seekEnabled |
boolean : True to enable seek, false otherwise
|
setSeekProvider
void setSeekProvider (PlaybackSeekDataProvider seekProvider)
Set seek data provider used during user seeking.
Parameters | |
---|---|
seekProvider |
PlaybackSeekDataProvider : Seek data provider used during user seeking.
|
Protected methods
onAttachedToHost
void onAttachedToHost (PlaybackGlueHost host)
This method is called attached to associated PlaybackGlueHost
. Subclass may override
and call super.onAttachedToHost().
Parameters | |
---|---|
host |
PlaybackGlueHost |
onCreatePrimaryActions
void onCreatePrimaryActions (ArrayObjectAdapter primaryActionsAdapter)
May be overridden to add primary actions to the adapter. Default implementation add
PlaybackControlsRow.PlayPauseAction
.
Parameters | |
---|---|
primaryActionsAdapter |
ArrayObjectAdapter : The adapter to add primary Action s.
|
onCreateRowPresenter
PlaybackRowPresenter onCreateRowPresenter ()
Returns | |
---|---|
PlaybackRowPresenter |
onDetachedFromHost
void onDetachedFromHost ()
This method is called when current associated PlaybackGlueHost
is attached to a
different PlaybackGlue
or PlaybackGlueHost
is destroyed . Subclass may
override and call super.onDetachedFromHost() at last. A typical PlaybackGlue will release
resources (e.g. MediaPlayer or connection to playback service) in this method.
onPlayStateChanged
void onPlayStateChanged ()
Event when play state changed.
Interfaces
Classes
- MediaControllerAdapter
- MediaControllerGlue
- MediaPlayerAdapter
- PlaybackBannerControlGlue
- PlaybackBaseControlGlue
- PlaybackControlGlue
- PlaybackGlue
- PlaybackGlue.PlayerCallback
- PlaybackGlueHost
- PlaybackGlueHost.HostCallback
- PlaybackGlueHost.PlayerCallback
- PlaybackTransportControlGlue
- PlayerAdapter
- PlayerAdapter.Callback