| java.lang.Object | |
| ↳ | android.media.RemoteControlClient |
RemoteControlClient enables exposing information meant to be consumed by remote controls capable of displaying metadata, artwork and media transport control buttons.
A remote control client object is associated with a media button event receiver. This
event receiver must have been previously registered with
registerMediaButtonEventReceiver(ComponentName) before the
RemoteControlClient can be registered through
registerRemoteControlClient(RemoteControlClient).
Here is an example of creating a RemoteControlClient instance after registering a media button event receiver:
ComponentName myEventReceiver = new ComponentName(getPackageName(), MyRemoteControlEventReceiver.class.getName()); AudioManager myAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); myAudioManager.registerMediaButtonEventReceiver(myEventReceiver); // build the PendingIntent for the remote control client Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(myEventReceiver); PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, mediaButtonIntent, 0); // create and register the remote control client RemoteControlClient myRemoteControlClient = new RemoteControlClient(mediaPendingIntent); myAudioManager.registerRemoteControlClient(myRemoteControlClient);
| Nested Classes | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| RemoteControlClient.MetadataEditor | Class used to modify metadata in a RemoteControlClient object. |
||||||||||
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| int | FLAG_KEY_MEDIA_FAST_FORWARD | Flag indicating a RemoteControlClient makes use of the "fast forward" media key. | |||||||||
| int | FLAG_KEY_MEDIA_NEXT | Flag indicating a RemoteControlClient makes use of the "next" media key. | |||||||||
| int | FLAG_KEY_MEDIA_PAUSE | Flag indicating a RemoteControlClient makes use of the "pause" media key. | |||||||||
| int | FLAG_KEY_MEDIA_PLAY | Flag indicating a RemoteControlClient makes use of the "play" media key. | |||||||||
| int | FLAG_KEY_MEDIA_PLAY_PAUSE | Flag indicating a RemoteControlClient makes use of the "play/pause" media key. | |||||||||
| int | FLAG_KEY_MEDIA_PREVIOUS | Flag indicating a RemoteControlClient makes use of the "previous" media key. | |||||||||
| int | FLAG_KEY_MEDIA_REWIND | Flag indicating a RemoteControlClient makes use of the "rewind" media key. | |||||||||
| int | FLAG_KEY_MEDIA_STOP | Flag indicating a RemoteControlClient makes use of the "stop" media key. | |||||||||
| int | PLAYSTATE_BUFFERING | Playback state of a RemoteControlClient which is buffering data to play before it can start or resume playback. | |||||||||
| int | PLAYSTATE_ERROR | Playback state of a RemoteControlClient which cannot perform any playback related operation because of an internal error. | |||||||||
| int | PLAYSTATE_FAST_FORWARDING | Playback state of a RemoteControlClient which is fast forwarding in the media it is currently playing. | |||||||||
| int | PLAYSTATE_PAUSED | Playback state of a RemoteControlClient which is paused. | |||||||||
| int | PLAYSTATE_PLAYING | Playback state of a RemoteControlClient which is playing media. | |||||||||
| int | PLAYSTATE_REWINDING | Playback state of a RemoteControlClient which is fast rewinding in the media it is currently playing. | |||||||||
| int | PLAYSTATE_SKIPPING_BACKWARDS | Playback state of a RemoteControlClient which is skipping back to the previous logical chapter (such as a song in a playlist) in the media it is currently playing. | |||||||||
| int | PLAYSTATE_SKIPPING_FORWARDS | Playback state of a RemoteControlClient which is skipping to the next logical chapter (such as a song in a playlist) in the media it is currently playing. | |||||||||
| int | PLAYSTATE_STOPPED | Playback state of a RemoteControlClient which is stopped. | |||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Class constructor.
| |||||||||||
Class constructor for a remote control client whose internal event handling
happens on a user-provided Looper.
| |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Creates a
RemoteControlClient.MetadataEditor. | |||||||||||
Sets the current playback state.
| |||||||||||
Sets the flags for the media transport control buttons that this client supports.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Flag indicating a RemoteControlClient makes use of the "fast forward" media key.
Flag indicating a RemoteControlClient makes use of the "next" media key.
Flag indicating a RemoteControlClient makes use of the "pause" media key.
Flag indicating a RemoteControlClient makes use of the "play" media key.
Flag indicating a RemoteControlClient makes use of the "play/pause" media key.
Flag indicating a RemoteControlClient makes use of the "previous" media key.
Flag indicating a RemoteControlClient makes use of the "rewind" media key.
Flag indicating a RemoteControlClient makes use of the "stop" media key.
Playback state of a RemoteControlClient which is buffering data to play before it can start or resume playback.
Playback state of a RemoteControlClient which cannot perform any playback related operation because of an internal error. Examples of such situations are no network connectivity when attempting to stream data from a server, or expired user credentials when trying to play subscription-based content.
Playback state of a RemoteControlClient which is fast forwarding in the media it is currently playing.
Playback state of a RemoteControlClient which is paused.
Playback state of a RemoteControlClient which is playing media.
Playback state of a RemoteControlClient which is fast rewinding in the media it is currently playing.
Playback state of a RemoteControlClient which is skipping back to the previous logical chapter (such as a song in a playlist) in the media it is currently playing.
Playback state of a RemoteControlClient which is skipping to the next logical chapter (such as a song in a playlist) in the media it is currently playing.
Playback state of a RemoteControlClient which is stopped.
Class constructor.
| mediaButtonIntent | The intent that will be sent for the media button events sent
by remote controls.
This intent needs to have been constructed with the ACTION_MEDIA_BUTTON
action, and have a component that will handle the intent (set with
setComponent(ComponentName)) registered with
registerMediaButtonEventReceiver(ComponentName)
before this new RemoteControlClient can itself be registered with
registerRemoteControlClient(RemoteControlClient). |
|---|
Class constructor for a remote control client whose internal event handling happens on a user-provided Looper.
| mediaButtonIntent | The intent that will be sent for the media button events sent
by remote controls.
This intent needs to have been constructed with the ACTION_MEDIA_BUTTON
action, and have a component that will handle the intent (set with
setComponent(ComponentName)) registered with
registerMediaButtonEventReceiver(ComponentName)
before this new RemoteControlClient can itself be registered with
registerRemoteControlClient(RemoteControlClient). |
|---|---|
| looper | The Looper running the event loop. |
Creates a RemoteControlClient.MetadataEditor.
| startEmpty | Set to false if you want the MetadataEditor to contain the metadata that was previously applied to the RemoteControlClient, or true if it is to be created empty. |
|---|
Sets the current playback state.
| state | The current playback state, one of the following values:
PLAYSTATE_STOPPED,
PLAYSTATE_PAUSED,
PLAYSTATE_PLAYING,
PLAYSTATE_FAST_FORWARDING,
PLAYSTATE_REWINDING,
PLAYSTATE_SKIPPING_FORWARDS,
PLAYSTATE_SKIPPING_BACKWARDS,
PLAYSTATE_BUFFERING,
PLAYSTATE_ERROR.
|
|---|
Sets the flags for the media transport control buttons that this client supports.
| transportControlFlags | A combination of the following flags:
FLAG_KEY_MEDIA_PREVIOUS,
FLAG_KEY_MEDIA_REWIND,
FLAG_KEY_MEDIA_PLAY,
FLAG_KEY_MEDIA_PLAY_PAUSE,
FLAG_KEY_MEDIA_PAUSE,
FLAG_KEY_MEDIA_STOP,
FLAG_KEY_MEDIA_FAST_FORWARD,
FLAG_KEY_MEDIA_NEXT
|
|---|