belongs to Maven artifact com.android.support:leanback-v17:28.0.0-alpha1
PlaybackBannerControlGlue
public
class
PlaybackBannerControlGlue
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.PlaybackBannerControlGlue<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 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
onCreateSecondaryActions(ArrayObjectAdapter) and respond to actions by overriding
onActionClicked(Action).
The subclass is responsible for implementing the "repeat mode" in
onPlayCompleted().
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 |
|---|
android.support.v17.leanback.media.PlaybackBaseControlGlue
|
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. |
boolean
|
onKey(View v, int keyCode, KeyEvent event)
Handles key events and returns true if handled. |
void
|
pause()
Pauses the media player. |
void
|
play()
Starts the media player. |
void
|
setControlsRow(PlaybackControlsRow controlsRow)
Sets the controls row to be managed by the glue layer. |
Protected methods | |
|---|---|
void
|
onCreatePrimaryActions(ArrayObjectAdapter primaryActionsAdapter)
May be overridden to add primary actions to the adapter. |
PlaybackRowPresenter
|
onCreateRowPresenter()
|
void
|
onPlayCompleted()
Event when play finishes, subclass may handling repeat mode here. |
void
|
onPlayStateChanged()
Event when play state changed. |
Inherited methods | |
|---|---|
android.support.v17.leanback.media.PlaybackBaseControlGlue
| |
android.support.v17.leanback.media.PlaybackGlue
| |
java.lang.Object
| |
android.support.v17.leanback.widget.OnActionClickedListener
| |
android.view.View.OnKeyListener
| |
Constants
ACTION_CUSTOM_LEFT_FIRST
int ACTION_CUSTOM_LEFT_FIRST
The adapter key for the first custom control on the left side of the predefined primary controls.
Constant Value: 1 (0x00000001)
ACTION_CUSTOM_RIGHT_FIRST
int ACTION_CUSTOM_RIGHT_FIRST
The adapter key for the first custom control on the right side of the predefined primary controls.
Constant Value: 4096 (0x00001000)
ACTION_FAST_FORWARD
int ACTION_FAST_FORWARD
The adapter key for the fast forward control.
Constant Value: 128 (0x00000080)
ACTION_PLAY_PAUSE
int ACTION_PLAY_PAUSE
The adapter key for the play/pause control.
Constant Value: 64 (0x00000040)
ACTION_REWIND
int ACTION_REWIND
The adapter key for the rewind control.
Constant Value: 32 (0x00000020)
ACTION_SKIP_TO_NEXT
int ACTION_SKIP_TO_NEXT
The adapter key for the skip to next control.
Constant Value: 256 (0x00000100)
ACTION_SKIP_TO_PREVIOUS
int ACTION_SKIP_TO_PREVIOUS
The adapter key for the skip to previous control.
Constant Value: 16 (0x00000010)
PLAYBACK_SPEED_FAST_L0
int PLAYBACK_SPEED_FAST_L0
The initial (level 0) fast forward playback speed. The negative of this value is for rewind at the same speed.
Constant Value: 10 (0x0000000a)
PLAYBACK_SPEED_FAST_L1
int PLAYBACK_SPEED_FAST_L1
The level 1 fast forward playback speed. The negative of this value is for rewind at the same speed.
Constant Value: 11 (0x0000000b)
PLAYBACK_SPEED_FAST_L2
int PLAYBACK_SPEED_FAST_L2
The level 2 fast forward playback speed. The negative of this value is for rewind at the same speed.
Constant Value: 12 (0x0000000c)
PLAYBACK_SPEED_FAST_L3
int PLAYBACK_SPEED_FAST_L3
The level 3 fast forward playback speed. The negative of this value is for rewind at the same speed.
Constant Value: 13 (0x0000000d)
PLAYBACK_SPEED_FAST_L4
int PLAYBACK_SPEED_FAST_L4
The level 4 fast forward playback speed. The negative of this value is for rewind at the same speed.
Constant Value: 14 (0x0000000e)
PLAYBACK_SPEED_INVALID
int PLAYBACK_SPEED_INVALID
Invalid playback speed.
Constant Value: -1 (0xffffffff)
PLAYBACK_SPEED_NORMAL
int PLAYBACK_SPEED_NORMAL
Speed representing playback state that is playing normally.
Constant Value: 1 (0x00000001)
PLAYBACK_SPEED_PAUSED
int PLAYBACK_SPEED_PAUSED
Speed representing playback state that is paused.
Constant Value: 0 (0x00000000)
Public constructors
PlaybackBannerControlGlue
PlaybackBannerControlGlue (Context context, int[] seekSpeeds, T impl)
Constructor for the glue.
| Parameters | |
|---|---|
seekSpeeds |
int: The array of seek speeds for fast forward and rewind. The maximum length of
the array is defined as NUMBER_OF_SEEK_SPEEDS. |
impl |
T: Implementation to underlying media player.
|
PlaybackBannerControlGlue
PlaybackBannerControlGlue (Context context, int[] fastForwardSpeeds, int[] rewindSpeeds, T impl)
Constructor for the glue.
| Parameters | |
|---|---|
fastForwardSpeeds |
int: The array of seek speeds for fast forward. The maximum length of
the array is defined as NUMBER_OF_SEEK_SPEEDS. |
rewindSpeeds |
int: The array of seek speeds for rewind. The maximum length of
the array is defined as NUMBER_OF_SEEK_SPEEDS. |
impl |
T: Implementation to underlying media player.
|
Public methods
getCurrentPosition
long getCurrentPosition ()
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.
| Returns | |
|---|---|
long |
Current position of the player. |
getFastForwardSpeeds
int[] getFastForwardSpeeds ()
Returns the fast forward speeds.
| Returns | |
|---|---|
int[] |
|
getRewindSpeeds
int[] getRewindSpeeds ()
Returns the rewind speeds.
| Returns | |
|---|---|
int[] |
|
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 |
|
play
void play ()
Starts the media player. Does nothing if isPrepared() is false. To wait
isPrepared() to be true before playing, use playWhenPrepared().
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 |
Protected methods
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 Actions.
|
onCreateRowPresenter
PlaybackRowPresenter onCreateRowPresenter ()
| Returns | |
|---|---|
PlaybackRowPresenter |
|
onPlayCompleted
void onPlayCompleted ()
Event when play finishes, subclass may handling repeat mode here.
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