public
class
MediaControlView
extends ViewGroup
A View that contains the controls for MediaController or SessionPlayer.
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
a SessionPlayer (e.g. MediaPlayer) and set it to this view
by calling setPlayer(SessionPlayer).
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
a MediaController attached to the MediaSession and set it to this view
by calling setMediaController(MediaController).
The easiest way to use a MediaControlView is by creating a VideoView, which
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 VideoView.
By default, each button in the MediaControlView is visible only when its corresponding
SessionCommand is included in the active SessionCommandGroup.
For more details, refer to MediaSession.setAllowedCommands(MediaSession.ControllerInfo, SessionCommandGroup).
UI transitions
The 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.
When the UI mode changes, MediaControlView animates the transition. The animation does not
start immediately, there is a default delay interval of 2000ms before the animation begins. You
can change this interval by calling
VideoView.setMediaControlView(MediaControlView, long).
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.
All touch/trackballs events are ignored while the system is animating the change between modes.
Customization
The following customizations are supported:
MediaControlView 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:
For video media, MediaMetadata.METADATA_KEY_TITLE metadata is supported.
If the value is not set, the following default value will be shown:
R.string.mcv2_non_music_title_unknown_text
Summary
Nested classes |
interface |
MediaControlView.OnFullScreenListener
Interface definition of a callback to be invoked to inform the fullscreen mode is changed.
|
Inherited constants |
From class
android.view.ViewGroup
int |
CLIP_TO_PADDING_MASK
|
int |
FOCUS_AFTER_DESCENDANTS
|
int |
FOCUS_BEFORE_DESCENDANTS
|
int |
FOCUS_BLOCK_DESCENDANTS
|
int |
LAYOUT_MODE_CLIP_BOUNDS
|
int |
LAYOUT_MODE_OPTICAL_BOUNDS
|
int |
PERSISTENT_ALL_CACHES
|
int |
PERSISTENT_ANIMATION_CACHE
|
int |
PERSISTENT_NO_CACHE
|
int |
PERSISTENT_SCROLLING_CACHE
|
|
From class
android.view.View
int |
ACCESSIBILITY_LIVE_REGION_ASSERTIVE
|
int |
ACCESSIBILITY_LIVE_REGION_NONE
|
int |
ACCESSIBILITY_LIVE_REGION_POLITE
|
int |
AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH
|
String |
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR
|
String |
AUTOFILL_HINT_CREDIT_CARD_NUMBER
|
String |
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE
|
String |
AUTOFILL_HINT_EMAIL_ADDRESS
|
String |
AUTOFILL_HINT_NAME
|
String |
AUTOFILL_HINT_PASSWORD
|
String |
AUTOFILL_HINT_PHONE
|
String |
AUTOFILL_HINT_POSTAL_ADDRESS
|
String |
AUTOFILL_HINT_POSTAL_CODE
|
String |
AUTOFILL_HINT_USERNAME
|
int |
AUTOFILL_TYPE_DATE
|
int |
AUTOFILL_TYPE_LIST
|
int |
AUTOFILL_TYPE_NONE
|
int |
AUTOFILL_TYPE_TEXT
|
int |
AUTOFILL_TYPE_TOGGLE
|
int |
DRAG_FLAG_GLOBAL
|
int |
DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION
|
int |
DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION
|
int |
DRAG_FLAG_GLOBAL_URI_READ
|
int |
DRAG_FLAG_GLOBAL_URI_WRITE
|
int |
DRAG_FLAG_OPAQUE
|
int |
DRAWING_CACHE_QUALITY_AUTO
|
int |
DRAWING_CACHE_QUALITY_HIGH
|
int |
DRAWING_CACHE_QUALITY_LOW
|
int |
FIND_VIEWS_WITH_CONTENT_DESCRIPTION
|
int |
FIND_VIEWS_WITH_TEXT
|
int |
FOCUSABLE
|
int |
FOCUSABLES_ALL
|
int |
FOCUSABLES_TOUCH_MODE
|
int |
FOCUSABLE_AUTO
|
int |
FOCUS_BACKWARD
|
int |
FOCUS_DOWN
|
int |
FOCUS_FORWARD
|
int |
FOCUS_LEFT
|
int |
FOCUS_RIGHT
|
int |
FOCUS_UP
|
int |
GONE
|
int |
HAPTIC_FEEDBACK_ENABLED
|
int |
IMPORTANT_FOR_ACCESSIBILITY_AUTO
|
int |
IMPORTANT_FOR_ACCESSIBILITY_NO
|
int |
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS
|
int |
IMPORTANT_FOR_ACCESSIBILITY_YES
|
int |
IMPORTANT_FOR_AUTOFILL_AUTO
|
int |
IMPORTANT_FOR_AUTOFILL_NO
|
int |
IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS
|
int |
IMPORTANT_FOR_AUTOFILL_YES
|
int |
IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS
|
int |
IMPORTANT_FOR_CONTENT_CAPTURE_AUTO
|
int |
IMPORTANT_FOR_CONTENT_CAPTURE_NO
|
int |
IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS
|
int |
IMPORTANT_FOR_CONTENT_CAPTURE_YES
|
int |
IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS
|
int |
INVISIBLE
|
int |
KEEP_SCREEN_ON
|
int |
LAYER_TYPE_HARDWARE
|
int |
LAYER_TYPE_NONE
|
int |
LAYER_TYPE_SOFTWARE
|
int |
LAYOUT_DIRECTION_INHERIT
|
int |
LAYOUT_DIRECTION_LOCALE
|
int |
LAYOUT_DIRECTION_LTR
|
int |
LAYOUT_DIRECTION_RTL
|
int |
MEASURED_HEIGHT_STATE_SHIFT
|
int |
MEASURED_SIZE_MASK
|
int |
MEASURED_STATE_MASK
|
int |
MEASURED_STATE_TOO_SMALL
|
int |
NOT_FOCUSABLE
|
int |
NO_ID
|
int |
OVER_SCROLL_ALWAYS
|
int |
OVER_SCROLL_IF_CONTENT_SCROLLS
|
int |
OVER_SCROLL_NEVER
|
int |
SCREEN_STATE_OFF
|
int |
SCREEN_STATE_ON
|
int |
SCROLLBARS_INSIDE_INSET
|
int |
SCROLLBARS_INSIDE_OVERLAY
|
int |
SCROLLBARS_OUTSIDE_INSET
|
int |
SCROLLBARS_OUTSIDE_OVERLAY
|
int |
SCROLLBAR_POSITION_DEFAULT
|
int |
SCROLLBAR_POSITION_LEFT
|
int |
SCROLLBAR_POSITION_RIGHT
|
int |
SCROLL_AXIS_HORIZONTAL
|
int |
SCROLL_AXIS_NONE
|
int |
SCROLL_AXIS_VERTICAL
|
int |
SCROLL_CAPTURE_HINT_AUTO
|
int |
SCROLL_CAPTURE_HINT_EXCLUDE
|
int |
SCROLL_CAPTURE_HINT_EXCLUDE_DESCENDANTS
|
int |
SCROLL_CAPTURE_HINT_INCLUDE
|
int |
SCROLL_INDICATOR_BOTTOM
|
int |
SCROLL_INDICATOR_END
|
int |
SCROLL_INDICATOR_LEFT
|
int |
SCROLL_INDICATOR_RIGHT
|
int |
SCROLL_INDICATOR_START
|
int |
SCROLL_INDICATOR_TOP
|
int |
SOUND_EFFECTS_ENABLED
|
int |
STATUS_BAR_HIDDEN
|
int |
STATUS_BAR_VISIBLE
|
int |
SYSTEM_UI_FLAG_FULLSCREEN
|
int |
SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
int |
SYSTEM_UI_FLAG_IMMERSIVE
|
int |
SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
int |
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
int |
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
int |
SYSTEM_UI_FLAG_LAYOUT_STABLE
|
int |
SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
int |
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
int |
SYSTEM_UI_FLAG_LOW_PROFILE
|
int |
SYSTEM_UI_FLAG_VISIBLE
|
int |
SYSTEM_UI_LAYOUT_FLAGS
|
int |
TEXT_ALIGNMENT_CENTER
|
int |
TEXT_ALIGNMENT_GRAVITY
|
int |
TEXT_ALIGNMENT_INHERIT
|
int |
TEXT_ALIGNMENT_TEXT_END
|
int |
TEXT_ALIGNMENT_TEXT_START
|
int |
TEXT_ALIGNMENT_VIEW_END
|
int |
TEXT_ALIGNMENT_VIEW_START
|
int |
TEXT_DIRECTION_ANY_RTL
|
int |
TEXT_DIRECTION_FIRST_STRONG
|
int |
TEXT_DIRECTION_FIRST_STRONG_LTR
|
int |
TEXT_DIRECTION_FIRST_STRONG_RTL
|
int |
TEXT_DIRECTION_INHERIT
|
int |
TEXT_DIRECTION_LOCALE
|
int |
TEXT_DIRECTION_LTR
|
int |
TEXT_DIRECTION_RTL
|
String |
VIEW_LOG_TAG
|
int |
VISIBLE
|
|
Inherited fields |
From class
android.view.View
public
static
final
Property<View, Float> |
ALPHA
|
protected
static
final
int[] |
EMPTY_STATE_SET
|
protected
static
final
int[] |
ENABLED_FOCUSED_SELECTED_STATE_SET
|
protected
static
final
int[] |
ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
ENABLED_FOCUSED_STATE_SET
|
protected
static
final
int[] |
ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
ENABLED_SELECTED_STATE_SET
|
protected
static
final
int[] |
ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
ENABLED_STATE_SET
|
protected
static
final
int[] |
ENABLED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
FOCUSED_SELECTED_STATE_SET
|
protected
static
final
int[] |
FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
FOCUSED_STATE_SET
|
protected
static
final
int[] |
FOCUSED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_SELECTED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_STATE_SET
|
protected
static
final
int[] |
PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_FOCUSED_SELECTED_STATE_SET
|
protected
static
final
int[] |
PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_SELECTED_STATE_SET
|
protected
static
final
int[] |
PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_STATE_SET
|
protected
static
final
int[] |
PRESSED_WINDOW_FOCUSED_STATE_SET
|
public
static
final
Property<View, Float> |
ROTATION
|
public
static
final
Property<View, Float> |
ROTATION_X
|
public
static
final
Property<View, Float> |
ROTATION_Y
|
public
static
final
Property<View, Float> |
SCALE_X
|
public
static
final
Property<View, Float> |
SCALE_Y
|
protected
static
final
int[] |
SELECTED_STATE_SET
|
protected
static
final
int[] |
SELECTED_WINDOW_FOCUSED_STATE_SET
|
public
static
final
Property<View, Float> |
TRANSLATION_X
|
public
static
final
Property<View, Float> |
TRANSLATION_Y
|
public
static
final
Property<View, Float> |
TRANSLATION_Z
|
protected
static
final
int[] |
WINDOW_FOCUSED_STATE_SET
|
public
static
final
Property<View, Float> |
X
|
public
static
final
Property<View, Float> |
Y
|
public
static
final
Property<View, Float> |
Z
|
|