Use Leanback transport controls

The Leanback library
has new playback controls that provide an improved user experience.
For video apps, the transport controls suppport video scrubbing with the
forward/backward controls. While scrubbing the display shows thumbnails to help
navigate through the video.

The library includes abstract classes as well as out-of-the-box implementations that provide more granular control for developers. Using the pre-built implementations you can quickly build a feature-rich app without much coding.
If you need more customization, you can extend any of the library's pre-built components.

Controls and player

The leanback library separates the UI with the transport controls from the
player that plays back video. This is accomplished with two components:
a playback fragment for displaying the transport controls (and optionally the video) and a player adapter to
encapsulate a media player.

PlayerAdapter

PlayerAdapter is an abstract class that
controls the underlying media player. Developers can chose
the pre-built MediaPlayerAdapter implementation, or write
their own implementation of this class.

Glueing the pieces together

You must use some "control glue" to connect the playback fragment
to the player. The leanback
library provides two kinds of glue:

PlaybackBannerControlGlue draws the
transport controls in the playback fragment in the "old style", placing them
inside an opaque background. (PlaybackBannerControlGlue
replaces PlaybackControlGlue,
which has been deprecated.)

You also need to specify a "glue host" that
binds the glue to the playback
fragment, draws the transport controls in the UI and maintains their state, and
passes transport control events back to the glue. The host must match the playback fragment type. Use
PlaybackFragmentGlueHost with
a PlaybackFragment, and
VideoFragmentGlueHost with a
VideoFragment.

Here's an illustration showing how the pieces of a leanback transport control
fit together:

The code that glues your app together should be inside the
PlaybackFragment or VideoFragment that defines the UI.

In the following
example, the app constructs an instance ofPlaybackTransportControlGlue,
naming it playerGlue,
and connects its VideoFragment to a newly-created MediaPlayerAdapter. Since
this is a VideoFragment the setup code calls setHost() to attach a
VideoFragmentGlueHost to playerGlue. The code is included inside the class
that extends the VideoFragment.

Adding controls

The actions in the PlaybackControlsRow
are assigned to two groups: primary actions and secondary
actions. Controls for the primary group appear above the seek bar and controls for the
secondary group appear below the seek bar. Initially, there is only a single primary action
for the play/pause button, and no secondary actions.