A View that contains the controls for
It provides a wide range of buttons that serve the following functions: play/pause,
rewind/fast-forward, skip to next/previous, select subtitle track, enter/exit full screen mode,
select audio track, and adjust playback speed.
For simple use cases not requiring communication with
MediaSession, apps need to create
MediaPlayer) and set it to this view
For more advanced use cases that require
MediaSession (e.g. handling media key events,
integrating with other MediaSession apps as Assistant), apps need to create
MediaController attached to the
MediaSession and set it to this view
The easiest way to use a MediaControlView is by creating a
internally creates a MediaControlView instance and handles all the commands from buttons inside
MediaControlView. It is also possible to create a MediaControlView programmatically and add it
to a custom video view. For more information, refer to
By default, each button in the MediaControlView is visible only when its corresponding
SessionCommand is included in the active
For more details, refer to
UI transitionsThe UI of an app can be in one of three modes:
- In full mode all the views, such as progress bar, title, transport controls, and other icons are visible.
- In progress-bar only mode the progress bar is the only visible element. The title, transport controls, and other icons are hidden.
- In None mode all the views are hidden.
User actions can change the scheduled transition during the delay interval according to the following logic:
- In Full mode
- If a touch/trackball event is received during the interval, the UI changes to None mode.
- If no touch/trackball event is received during the interval, the UI changes to progress-bar only mode.
- In Progress-bar only mode
- If a touch/trackball event is received, the UI changes to Full mode.
- If no touch/trackball event is received, the UI changes to None mode.
- In None mode, if a touch/trackball event is received, the UI changes to Full mode.
CustomizationThe following customizations are supported:
- Set focus to the play/pause button by calling
- Set full screen behavior by calling
setOnFullScreenListener(OnFullScreenListener). Calling this method will also show the full screen button.
Displaying metadataMediaControlView supports displaying metadata by calling
MediaItem.setMetadata(MediaMetadata). Metadata display is different for two different media types: video (with or without sound) and audio(sound only, no video)
The following table shows the metadata displayed on VideoView and the default values assigned if the keys are not set:
Interface definition of a callback to be invoked to inform the fullscreen mode is changed.