io.vov.vitamio.widget
Class MediaController

java.lang.Object
  extended by FrameLayout
      extended by io.vov.vitamio.widget.MediaController

public class MediaController
extends FrameLayout

A view containing controls for a MediaPlayer. Typically contains the buttons like "Play/Pause" 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 programatically. 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.


Nested Class Summary
static interface MediaController.MediaPlayerControl
           
 
Constructor Summary
MediaController(Context context)
           
MediaController(Context context, AttributeSet attrs)
           
 
Method Summary
 boolean dispatchKeyEvent(KeyEvent event)
           
 void hide()
           
 boolean isShowing()
           
 void onFinishInflate()
           
 boolean onTouchEvent(MotionEvent event)
           
 boolean onTrackballEvent(MotionEvent ev)
           
 void setAnchorView(View view)
          Set the view that acts as the anchor for the control view.
 void setEnabled(boolean enabled)
           
 void setFileName(java.lang.String name)
           
 void setInfoView(TextView v)
           
 void setMediaPlayer(MediaController.MediaPlayerControl player)
           
 void show()
           
 void show(int timeout)
          Show the controller on screen.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MediaController

public MediaController(Context context,
                       AttributeSet attrs)

MediaController

public MediaController(Context context)
Method Detail

onFinishInflate

public void onFinishInflate()

setAnchorView

public void setAnchorView(View view)
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.

Parameters:
view - The view to which to anchor the controller when it is visible.

setMediaPlayer

public void setMediaPlayer(MediaController.MediaPlayerControl player)

show

public void show()

setFileName

public void setFileName(java.lang.String name)

setInfoView

public void setInfoView(TextView v)

show

public void show(int timeout)
Show the controller on screen. It will go away automatically after 'timeout' milliseconds of inactivity.

Parameters:
timeout - The timeout in milliseconds. Use 0 to show the controller until hide() is called.

isShowing

public boolean isShowing()

hide

public void hide()

onTouchEvent

public boolean onTouchEvent(MotionEvent event)

onTrackballEvent

public boolean onTrackballEvent(MotionEvent ev)

dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent event)

setEnabled

public void setEnabled(boolean enabled)