MediaSession
instead.@Deprecated public class RemoteControlClient extends Object
A remote control client object is associated with a media button event receiver. This
event receiver must have been previously registered with
AudioManager.registerMediaButtonEventReceiver(ComponentName)
before the
RemoteControlClient can be registered through
AudioManager.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);
Modifier and Type | Class and Description |
---|---|
class |
RemoteControlClient.MetadataEditor
Deprecated.
Use
MediaMetadata and MediaSession instead. |
static interface |
RemoteControlClient.OnGetPlaybackPositionListener
Deprecated.
Interface definition for a callback to be invoked when the media playback position is
queried.
|
static interface |
RemoteControlClient.OnMetadataUpdateListener
Deprecated.
Interface definition for a callback to be invoked when one of the metadata values has
been updated.
|
static interface |
RemoteControlClient.OnPlaybackPositionUpdateListener
Deprecated.
Interface definition for a callback to be invoked when the media playback position is
requested to be updated.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PLAYBACK_VOLUME
Deprecated.
|
static int |
DEFAULT_PLAYBACK_VOLUME_HANDLING
Deprecated.
|
static int |
FLAG_INFORMATION_REQUEST_ALBUM_ART
Deprecated.
|
static int |
FLAG_INFORMATION_REQUEST_KEY_MEDIA
Deprecated.
|
static int |
FLAG_INFORMATION_REQUEST_METADATA
Deprecated.
|
static int |
FLAG_INFORMATION_REQUEST_PLAYSTATE
Deprecated.
|
static int |
FLAG_KEY_MEDIA_FAST_FORWARD
Deprecated.
Flag indicating a RemoteControlClient makes use of the "fast forward" media key.
|
static int |
FLAG_KEY_MEDIA_NEXT
Deprecated.
Flag indicating a RemoteControlClient makes use of the "next" media key.
|
static int |
FLAG_KEY_MEDIA_PAUSE
Deprecated.
Flag indicating a RemoteControlClient makes use of the "pause" media key.
|
static int |
FLAG_KEY_MEDIA_PLAY
Deprecated.
Flag indicating a RemoteControlClient makes use of the "play" media key.
|
static int |
FLAG_KEY_MEDIA_PLAY_PAUSE
Deprecated.
Flag indicating a RemoteControlClient makes use of the "play/pause" media key.
|
static int |
FLAG_KEY_MEDIA_POSITION_UPDATE
Deprecated.
Flag indicating a RemoteControlClient can receive changes in the media playback position
through the
RemoteControlClient.OnPlaybackPositionUpdateListener interface. |
static int |
FLAG_KEY_MEDIA_PREVIOUS
Deprecated.
Flag indicating a RemoteControlClient makes use of the "previous" media key.
|
static int |
FLAG_KEY_MEDIA_RATING
Deprecated.
Flag indicating a RemoteControlClient supports ratings.
|
static int |
FLAG_KEY_MEDIA_REWIND
Deprecated.
Flag indicating a RemoteControlClient makes use of the "rewind" media key.
|
static int |
FLAG_KEY_MEDIA_STOP
Deprecated.
Flag indicating a RemoteControlClient makes use of the "stop" media key.
|
static int |
FLAGS_KEY_MEDIA_NONE
Deprecated.
|
static int |
MEDIA_POSITION_READABLE
Deprecated.
|
static int |
MEDIA_POSITION_WRITABLE
Deprecated.
|
static long |
PLAYBACK_POSITION_ALWAYS_UNKNOWN
Deprecated.
|
static long |
PLAYBACK_POSITION_INVALID
Deprecated.
|
static float |
PLAYBACK_SPEED_1X
Deprecated.
|
static int |
PLAYBACK_TYPE_LOCAL
Deprecated.
|
static int |
PLAYBACK_TYPE_REMOTE
Deprecated.
|
static int |
PLAYBACK_VOLUME_FIXED
Deprecated.
|
static int |
PLAYBACK_VOLUME_VARIABLE
Deprecated.
|
static int |
PLAYBACKINFO_INVALID_VALUE
Deprecated.
|
static int |
PLAYBACKINFO_PLAYBACK_TYPE
Deprecated.
|
static int |
PLAYBACKINFO_USES_STREAM
Deprecated.
|
static int |
PLAYBACKINFO_VOLUME
Deprecated.
|
static int |
PLAYBACKINFO_VOLUME_HANDLING
Deprecated.
|
static int |
PLAYBACKINFO_VOLUME_MAX
Deprecated.
|
static int |
PLAYSTATE_BUFFERING
Deprecated.
Playback state of a RemoteControlClient which is buffering data to play before it can
start or resume playback.
|
static int |
PLAYSTATE_ERROR
Deprecated.
Playback state of a RemoteControlClient which cannot perform any playback related
operation because of an internal error.
|
static int |
PLAYSTATE_FAST_FORWARDING
Deprecated.
Playback state of a RemoteControlClient which is fast forwarding in the media
it is currently playing.
|
static int |
PLAYSTATE_NONE
Deprecated.
|
static int |
PLAYSTATE_PAUSED
Deprecated.
Playback state of a RemoteControlClient which is paused.
|
static int |
PLAYSTATE_PLAYING
Deprecated.
Playback state of a RemoteControlClient which is playing media.
|
static int |
PLAYSTATE_REWINDING
Deprecated.
Playback state of a RemoteControlClient which is fast rewinding in the media
it is currently playing.
|
static int |
PLAYSTATE_SKIPPING_BACKWARDS
Deprecated.
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.
|
static int |
PLAYSTATE_SKIPPING_FORWARDS
Deprecated.
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.
|
static int |
PLAYSTATE_STOPPED
Deprecated.
Playback state of a RemoteControlClient which is stopped.
|
static int |
RCSE_ID_UNREGISTERED
Deprecated.
|
Constructor and Description |
---|
RemoteControlClient(PendingIntent mediaButtonIntent)
Deprecated.
Class constructor.
|
RemoteControlClient(PendingIntent mediaButtonIntent,
Looper looper)
Deprecated.
Class constructor for a remote control client whose internal event handling
happens on a user-provided Looper.
|
Modifier and Type | Method and Description |
---|---|
RemoteControlClient.MetadataEditor |
editMetadata(boolean startEmpty)
Deprecated.
Creates a
RemoteControlClient.MetadataEditor . |
MediaSession |
getMediaSession()
Deprecated.
Get a
MediaSession associated with this RCC. |
PendingIntent |
getRcMediaIntent()
Deprecated.
|
void |
registerWithSession(MediaSessionLegacyHelper helper)
Deprecated.
|
void |
setMetadataUpdateListener(RemoteControlClient.OnMetadataUpdateListener l)
Deprecated.
Sets the listener to be called whenever the metadata is updated.
|
void |
setOnGetPlaybackPositionListener(RemoteControlClient.OnGetPlaybackPositionListener l)
Deprecated.
Sets the listener to be called whenever the media current playback position is needed.
|
void |
setPlaybackPositionUpdateListener(RemoteControlClient.OnPlaybackPositionUpdateListener l)
Deprecated.
Sets the listener to be called whenever the media playback position is requested
to be updated.
|
void |
setPlaybackState(int state)
Deprecated.
Sets the current playback state.
|
void |
setPlaybackState(int state,
long timeInMs,
float playbackSpeed)
Deprecated.
Sets the current playback state and the matching media position for the current playback
speed.
|
void |
setTransportControlFlags(int transportControlFlags)
Deprecated.
Sets the flags for the media transport control buttons that this client supports.
|
void |
unregisterWithSession(MediaSessionLegacyHelper helper)
Deprecated.
|
public static final int PLAYSTATE_STOPPED
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_PAUSED
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_PLAYING
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_FAST_FORWARDING
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_REWINDING
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_SKIPPING_FORWARDS
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_SKIPPING_BACKWARDS
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_BUFFERING
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_ERROR
setPlaybackState(int)
,
Constant Field Valuespublic static final int PLAYSTATE_NONE
public static final int PLAYBACK_TYPE_LOCAL
public static final int PLAYBACK_TYPE_REMOTE
public static final int PLAYBACK_VOLUME_FIXED
#PLAYBACKINFO_VOLUME_HANDLING.
,
Constant Field Valuespublic static final int PLAYBACK_VOLUME_VARIABLE
#PLAYBACKINFO_VOLUME_HANDLING.
,
Constant Field Valuespublic static final int PLAYBACKINFO_INVALID_VALUE
#PLAYBACKINFO_VOLUME_HANDLING.
,
Constant Field Valuespublic static final long PLAYBACK_POSITION_INVALID
public static final long PLAYBACK_POSITION_ALWAYS_UNKNOWN
public static final float PLAYBACK_SPEED_1X
public static final int PLAYBACKINFO_PLAYBACK_TYPE
public static final int PLAYBACKINFO_VOLUME
public static final int PLAYBACKINFO_VOLUME_MAX
public static final int PLAYBACKINFO_VOLUME_HANDLING
public static final int PLAYBACKINFO_USES_STREAM
public static final int FLAG_KEY_MEDIA_PREVIOUS
public static final int FLAG_KEY_MEDIA_REWIND
public static final int FLAG_KEY_MEDIA_PLAY
public static final int FLAG_KEY_MEDIA_PLAY_PAUSE
public static final int FLAG_KEY_MEDIA_PAUSE
public static final int FLAG_KEY_MEDIA_STOP
public static final int FLAG_KEY_MEDIA_FAST_FORWARD
public static final int FLAG_KEY_MEDIA_NEXT
public static final int FLAG_KEY_MEDIA_POSITION_UPDATE
RemoteControlClient.OnPlaybackPositionUpdateListener
interface. This flag must be set
in order for components that display the RemoteControlClient information, to display and
let the user control media playback position.public static final int FLAG_KEY_MEDIA_RATING
MediaMetadataEditor.addEditableKey(int)
with the
MediaMetadataEditor.RATING_KEY_BY_USER
key), it will enable the user to rate
the media, with values being received through the interface set with
setMetadataUpdateListener(OnMetadataUpdateListener)
.public static final int FLAGS_KEY_MEDIA_NONE
public static final int FLAG_INFORMATION_REQUEST_METADATA
public static final int FLAG_INFORMATION_REQUEST_KEY_MEDIA
public static final int FLAG_INFORMATION_REQUEST_PLAYSTATE
public static final int FLAG_INFORMATION_REQUEST_ALBUM_ART
public static int MEDIA_POSITION_READABLE
public static int MEDIA_POSITION_WRITABLE
public static final int DEFAULT_PLAYBACK_VOLUME_HANDLING
public static final int DEFAULT_PLAYBACK_VOLUME
public static final int RCSE_ID_UNREGISTERED
public RemoteControlClient(PendingIntent mediaButtonIntent)
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 Intent.ACTION_MEDIA_BUTTON
action, and have a component that will handle the intent (set with
Intent.setComponent(ComponentName)
) registered with
AudioManager.registerMediaButtonEventReceiver(ComponentName)
before this new RemoteControlClient can itself be registered with
AudioManager.registerRemoteControlClient(RemoteControlClient)
.AudioManager.registerMediaButtonEventReceiver(ComponentName)
,
AudioManager.registerRemoteControlClient(RemoteControlClient)
public RemoteControlClient(PendingIntent mediaButtonIntent, Looper 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 Intent.ACTION_MEDIA_BUTTON
action, and have a component that will handle the intent (set with
Intent.setComponent(ComponentName)
) registered with
AudioManager.registerMediaButtonEventReceiver(ComponentName)
before this new RemoteControlClient can itself be registered with
AudioManager.registerRemoteControlClient(RemoteControlClient)
.looper
- The Looper running the event loop.AudioManager.registerMediaButtonEventReceiver(ComponentName)
,
AudioManager.registerRemoteControlClient(RemoteControlClient)
public void registerWithSession(MediaSessionLegacyHelper helper)
public void unregisterWithSession(MediaSessionLegacyHelper helper)
public MediaSession getMediaSession()
MediaSession
associated with this RCC. It will only have a
session while it is registered with
AudioManager.registerRemoteControlClient(android.media.RemoteControlClient)
. The session returned
should not be modified directly by the application but may be used with
other APIs that require a session.public RemoteControlClient.MetadataEditor editMetadata(boolean startEmpty)
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.public void setPlaybackState(int 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
.public void setPlaybackState(int state, long timeInMs, float playbackSpeed)
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
.timeInMs
- a 0 or positive value for the current media position expressed in ms
(same unit as for when sending the media duration, if applicable, with
MediaMetadataRetriever.METADATA_KEY_DURATION
in the
RemoteControlClient.MetadataEditor
). Negative values imply that position is not
known (e.g. listening to a live stream of a radio) or not applicable (e.g. when state
is PLAYSTATE_BUFFERING
and nothing had played yet).playbackSpeed
- a value expressed as a ratio of 1x playback: 1.0f is normal playback,
2.0f is 2x, 0.5f is half-speed, -2.0f is rewind at 2x speed. 0.0f means nothing is
playing (e.g. when state is PLAYSTATE_ERROR
).public void setTransportControlFlags(int transportControlFlags)
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
,
FLAG_KEY_MEDIA_POSITION_UPDATE
,
FLAG_KEY_MEDIA_RATING
.public void setMetadataUpdateListener(RemoteControlClient.OnMetadataUpdateListener l)
l
- the metadata update listenerpublic void setPlaybackPositionUpdateListener(RemoteControlClient.OnPlaybackPositionUpdateListener l)
l
- the position update listener to be calledpublic void setOnGetPlaybackPositionListener(RemoteControlClient.OnGetPlaybackPositionListener l)
l
- the listener to be called to retrieve the playback positionpublic PendingIntent getRcMediaIntent()