MediaController

A view containing controls for a MediaPlayer. Typically contains the
buttons like "Play/Pause", "Rewind", "Fast Forward" and a progress
slider. It takes care of synchronizing the controls with the state
of the MediaPlayer.

The way to use this class is to instantiate it programmatically.
The MediaController will create a default set of controls
and put them in a window floating above your application. Specifically,
the controls will float above the view specified with setAnchorView().
The window will disappear if left idle for three seconds and reappear
when the user touches the anchor view.

Functions like show() and hide() have no effect when MediaController
is created in an xml layout.
MediaController will hide and
show the buttons according to these rules:

The "previous" and "next" buttons are hidden until setPrevNextListeners()
has been called

The "previous" and "next" buttons are visible but disabled if
setPrevNextListeners() was called with null listeners

The "rewind" and "fastforward" buttons are shown unless requested
otherwise by using the MediaController(Context, boolean) constructor
with the boolean set to false

Defines the next view to give focus to when the next focus is
FOCUS_DOWN
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.

Defines the next view to give focus to when the next focus is
FOCUS_FORWARD
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.

Defines the next view to give focus to when the next focus is
FOCUS_RIGHT
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.

Defines the next view to give focus to when the next focus is
FOCUS_UP
If the reference refers to a view that does not exist or is part
of a hierarchy that is invisible, a RuntimeException
will result when the reference is accessed.

Flag for setSystemUiVisibility(int): View has requested to go
into the normal fullscreen mode so that its content can take over the screen
while still allowing the user to interact with the application.

Indicates whether the view is currently tracking transient state that the
app should not need to concern itself with saving and restoring, but that
the framework should take special note to preserve when possible.

This method was deprecated
in API level 23.
As of M, this property is ignored.
Child views may no longer be forced to cache their rendering state by their parents.
Use setLayerType(int, Paint) on individual Views instead.

Call this to try to give focus to a specific view or to one of its descendants
and give it hints about the direction and a specific rectangle that the focus
is coming from.
Looks for a view to give focus to respecting the setting specified by
getDescendantFocusability().

This method was deprecated
in API level 23.
As of M, this property is ignored.
Child views may no longer be forced to cache their rendering state by their parents.
Use setLayerType(int, Paint) on individual Views instead.

This method tells the ViewGroup that the given View object, which should have this
ViewGroup as its parent,
should be kept around (re-displayed when the ViewGroup draws its children) even if it
is removed from its parent.

Convenience method for sending a TYPE_ANNOUNCEMENTAccessibilityEvent to make an announcement which is related to some
sort of a context change for which none of the events representing UI transitions
is a good fit.

Indicates whether the view is currently tracking transient state that the
app should not need to concern itself with saving and restoring, but that
the framework should take special note to preserve when possible.

Sets whether or not this view should account for system screen decorations
such as the status bar and inset its content; that is, controlling whether
the default implementation of fitSystemWindows(Rect) will be
executed.

Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.

MediaController

Public methods

dispatchKeyEvent

Dispatch a key event to the next view on the focus path. This path runs
from the top of the view tree down to the currently focused view. If this
view has focus, it will dispatch to itself. Otherwise it will dispatch
the next node down the focus path. This method also fires any key
listeners.

Parameters

event

KeyEvent:
The key event to be dispatched.

Returns

boolean

True if the event was handled, false otherwise.

getAccessibilityClassName

Return the class name of this object to be used for accessibility purposes.
Subclasses should only override this if they are implementing something that
should be seen as a completely new class of view when used by accessibility,
unrelated to the class it is deriving from. This is used to fill in
AccessibilityNodeInfo.setClassName.

onTrackballEvent

Implement this method to handle trackball motion events. The
relative movement of the trackball since the last event
can be retrieve with MotionEvent.getX() and
MotionEvent.getY(). These are normalized so
that a movement of 1 corresponds to the user pressing one DPAD key (so
they will often be fractional values, representing the more fine-grained
movement information available from a trackball).

Parameters

ev

MotionEvent:
The motion event.

Returns

boolean

True if the event was handled, false otherwise.

setAnchorView

Set the view that acts as the anchor for the control view.
This can for example be a VideoView, or your Activity's main view.
When VideoView calls this method, it will use the VideoView's parent
as the anchor.