java.lang.Object | |
↳ | android.support.v17.leanback.app.PlaybackControlGlue |
Known Direct Subclasses |
A helper class for managing a PlaybackControlsRow
and
PlaybackOverlayFragment
that implements a recommended approach to handling standard
playback control actions such as play/pause, fast forward/rewind at progressive speed levels,
and skip to next/previous. This helper class is a glue layer in that it manages the
configuration of and interaction between the leanback UI components by defining a functional
interface to the media player.
You can instantiate a concrete subclass such as MediaControllerGlue
or you must
subclass this abstract helper. To create a subclass you must implement all of the
abstract methods and the subclass must invoke onMetadataChanged()
and
onStateChanged()
appropriately.
To use an instance of the glue layer, first construct an instance. Constructor parameters
inform the glue what speed levels are supported for fast forward/rewind. If you have your own
controls row you must pass it to setControlsRow(PlaybackControlsRow)
. The row will be updated by the glue
layer based on the media metadata and playback state. Alternatively, you may call
createControlsRowAndPresenter()
which will set a controls row and return
a row presenter you can use to present the row.
The helper sets a SparseArrayObjectAdapter
on the controls row as the primary actions adapter, and adds actions to it. You can provide
additional actions by overriding createPrimaryActionsAdapter(PresenterSelector)
. This helper does not
deal in secondary actions so those you may add separately.
The helper sets an OnItemViewClickedListener
on the fragment. To receive callbacks on clicks for elements unknown to the helper, pass
a listener to setOnItemViewClickedListener(OnItemViewClickedListener)
.
To update the controls row progress during playback, override enableProgressUpdating(boolean)
to manage the lifecycle of a periodic callback to updateProgress()
.
getUpdatePeriod()
provides a recommended update period.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | ACTION_CUSTOM_LEFT_FIRST | The adapter key for the first custom control on the right 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. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor for the glue.
| |||||||||||
Constructor for the glue.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Helper method for instantiating a
PlaybackControlsRow and corresponding
PlaybackControlsRowPresenter .
| |||||||||||
Override this to start/stop a runnable to call
updateProgress() at
an interval such as getUpdatePeriod() .
| |||||||||||
Returns the context.
| |||||||||||
Returns the playback controls row managed by the glue layer.
| |||||||||||
Returns the current position of the media item in milliseconds.
| |||||||||||
Returns the current playback speed.
| |||||||||||
Returns the fast forward speeds.
| |||||||||||
Returns the fragment.
| |||||||||||
Returns a bitmap of the art for the media item.
| |||||||||||
Returns the duration of the media item in milliseconds.
| |||||||||||
Returns the subtitle of the media item.
| |||||||||||
Returns the title of the media item.
| |||||||||||
Returns the
OnItemViewClickedListener .
| |||||||||||
Returns the rewind speeds.
| |||||||||||
Returns a bitmask of actions supported by the media player.
| |||||||||||
Returns the time period in milliseconds that should be used
to update the progress.
| |||||||||||
Returns true if there is a valid media item.
| |||||||||||
Returns true if controls are set to fade when media is playing.
| |||||||||||
Returns true if media is currently playing.
| |||||||||||
Sets the controls row to be managed by the glue layer.
| |||||||||||
Sets the controls to fade after a timeout when media is playing.
| |||||||||||
Set the
OnItemViewClickedListener to be called if the click event
is not handled internally.
| |||||||||||
Updates the progress bar based on the current media playback position.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates the primary action adapter.
| |||||||||||
Must be called appropriately by a subclass when the metadata state has changed.
| |||||||||||
Invoked when the playback controls row has changed.
| |||||||||||
Must be called appropriately by a subclass when the playback state has changed.
| |||||||||||
Pause playback.
| |||||||||||
Skip to the next track.
| |||||||||||
Skip to the previous track.
| |||||||||||
Start playback at the given speed.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
The adapter key for the first custom control on the right side of the predefined primary controls.
The adapter key for the first custom control on the right side of the predefined primary controls.
The adapter key for the fast forward control.
The adapter key for the play/pause control.
The adapter key for the rewind control.
The adapter key for the skip to next control.
The adapter key for the skip to previous control.
The initial (level 0) fast forward playback speed. The negative of this value is for rewind at the same speed.
The level 1 fast forward playback speed. The negative of this value is for rewind at the same speed.
The level 2 fast forward playback speed. The negative of this value is for rewind at the same speed.
The level 3 fast forward playback speed. The negative of this value is for rewind at the same speed.
The level 4 fast forward playback speed. The negative of this value is for rewind at the same speed.
Invalid playback speed.
Speed representing playback state that is playing normally.
Speed representing playback state that is paused.
Constructor for the glue.
The PlaybackOverlayFragment
must be passed in.
A OnItemViewClickedListener
and PlaybackOverlayFragment.InputEventHandler
will be set on the fragment.
seekSpeeds | Array of seek speeds for fast forward and rewind. |
---|
Constructor for the glue.
The PlaybackOverlayFragment
must be passed in.
A OnItemViewClickedListener
and PlaybackOverlayFragment.InputEventHandler
will be set on the fragment.
fastForwardSpeeds | Array of seek speeds for fast forward. |
---|---|
rewindSpeeds | Array of seek speeds for rewind. |
Helper method for instantiating a
PlaybackControlsRow
and corresponding
PlaybackControlsRowPresenter
.
Override this to start/stop a runnable to call updateProgress()
at
an interval such as getUpdatePeriod()
.
Returns the playback controls row managed by the glue layer.
Returns the current position of the media item in milliseconds.
Returns the current playback speed. When playing normally,
PLAYBACK_SPEED_NORMAL
should be returned.
Returns the fast forward speeds.
Returns the duration of the media item in milliseconds.
Returns the OnItemViewClickedListener
.
Returns the rewind speeds.
Returns a bitmask of actions supported by the media player.
Returns the time period in milliseconds that should be used
to update the progress. See updateProgress()
.
Returns true if there is a valid media item.
Returns true if controls are set to fade when media is playing.
Returns true if media is currently playing.
Sets the controls row to be managed by the glue layer. The primary actions and playback state related aspects of the row are updated by the glue.
Sets the controls to fade after a timeout when media is playing.
Set the OnItemViewClickedListener
to be called if the click event
is not handled internally.
Updates the progress bar based on the current media playback position.
Creates the primary action adapter. May be overridden to add additional primary actions to the adapter.
Must be called appropriately by a subclass when the metadata state has changed.
Invoked when the playback controls row has changed. The adapter containing this row should be notified.
Must be called appropriately by a subclass when the playback state has changed.
Pause playback.
Skip to the next track.
Skip to the previous track.
Start playback at the given speed.
speed | The desired playback speed. For normal playback this will be
PLAYBACK_SPEED_NORMAL ; higher positive values for fast forward,
and negative values for rewind.
|
---|