|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectandroid.support.v4.media.TransportPerformer
public abstract class TransportPerformer
Implemented by the playback side of the media system, to respond to requests to perform actions and to retrieve its current state. These requests may either come from key events dispatched directly to your UI, or events sent over a media button event receiver that this class keeps active while your window is in focus.
Constructor Summary | |
---|---|
TransportPerformer()
|
Method Summary | |
---|---|
void |
onAudioFocusChange(int focusChange)
Report that audio focus has changed on the app. |
int |
onGetBufferPercentage()
Request to find out how much of the media has been buffered on the local device. |
abstract long |
onGetCurrentPosition()
Request to return the current playback position, in milliseconds. |
abstract long |
onGetDuration()
Request to return the duration of the current media, in milliseconds. |
int |
onGetTransportControlFlags()
Retrieves the flags for the media transport control buttons that this transport supports. |
abstract boolean |
onIsPlaying()
Request to find out whether the player is currently playing its media. |
boolean |
onMediaButtonDown(int keyCode,
android.view.KeyEvent event)
Report that a media button has been pressed. |
boolean |
onMediaButtonUp(int keyCode,
android.view.KeyEvent event)
Report that a media button has been released. |
abstract void |
onPause()
Request to pause playback of the media, staying at the current playback position and other state so a later call to onStart() will resume at the same place. |
abstract void |
onSeekTo(long pos)
Request to move the current playback position. |
abstract void |
onStart()
Request to start playback on the media, resuming from whatever current state (position etc) it is in. |
abstract void |
onStop()
Request to completely stop playback of the media, clearing whatever state the player thinks is appropriate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TransportPerformer()
Method Detail |
---|
public abstract void onStart()
public abstract void onPause()
onStart()
will resume at the same place.
public abstract void onStop()
public abstract long onGetDuration()
public abstract long onGetCurrentPosition()
public abstract void onSeekTo(long pos)
pos
- New position to move to, in milliseconds.public abstract boolean onIsPlaying()
public int onGetBufferPercentage()
public int onGetTransportControlFlags()
TransportMediator.FLAG_KEY_MEDIA_PREVIOUS
,
TransportMediator.FLAG_KEY_MEDIA_REWIND
,
TransportMediator.FLAG_KEY_MEDIA_PLAY
,
TransportMediator.FLAG_KEY_MEDIA_PLAY_PAUSE
,
TransportMediator.FLAG_KEY_MEDIA_PAUSE
,
TransportMediator.FLAG_KEY_MEDIA_STOP
,
TransportMediator.FLAG_KEY_MEDIA_FAST_FORWARD
,
TransportMediator.FLAG_KEY_MEDIA_NEXT
The default implementation returns:
TransportMediator.FLAG_KEY_MEDIA_PLAY
,
TransportMediator.FLAG_KEY_MEDIA_PLAY_PAUSE
,
TransportMediator.FLAG_KEY_MEDIA_PAUSE
, and
TransportMediator.FLAG_KEY_MEDIA_STOP
public boolean onMediaButtonDown(int keyCode, android.view.KeyEvent event)
KeyEvent.Callback.onKeyDown(int, android.view.KeyEvent)
but
will only deliver media keys. The default implementation handles these keys:
onStart()
onPause()
onStop()
onPause()
if onIsPlaying()
returns true, otherwise call onStart()
keyCode
- The code of the media key.event
- The full key event.
TransportController.dispatchKeyEvent
, and determines whether the key
continues on to its default key handling (which for media keys means
being delivered to the current media remote control, which should
be us).public boolean onMediaButtonUp(int keyCode, android.view.KeyEvent event)
KeyEvent.Callback#onKeyUp(int, android.view.KeyEvent)
but
will only deliver media keys. The default implementation does nothing.
keyCode
- The code of the media key.event
- The full key event.
TransportController.dispatchKeyEvent
, and determines whether the key
continues on to its default key handling (which for media keys means
being delivered to the current media remote control, which should
be us).public void onAudioFocusChange(int focusChange)
TransportController.startPlaying
,
which takes audio focus for you.
focusChange
- The type of focus change, as per
OnAudioFocusChangeListener.onAudioFocusChange
. The default implementation will
deliver a KeyEvent.KEYCODE_MEDIA_STOP
when receiving android.media.AudioManager#AUDIOFOCUS_LOSS
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |