MediaController
instead.@Deprecated public final class RemoteController extends Object
RemoteControlClient
class.
A RemoteController shall be registered through
AudioManager.registerRemoteController(RemoteController)
in order for the system to send
media event updates to the RemoteController.OnClientUpdateListener
listener set in the class constructor.
Implement the methods of the interface to receive the information published by the active
RemoteControlClient
instances.
By default an RemoteController.OnClientUpdateListener
implementation will not receive bitmaps for
album art. Use setArtworkConfiguration(int, int)
to receive images as well.
Registration requires the RemoteController.OnClientUpdateListener
listener to be one of the enabled
notification listeners (see NotificationListenerService
).
Modifier and Type | Class and Description |
---|---|
class |
RemoteController.MetadataEditor
Deprecated.
A class to read the metadata published by a
RemoteControlClient , or send a
RemoteControlClient new values for keys that can be edited. |
static interface |
RemoteController.OnClientUpdateListener
Deprecated.
Interface definition for the callbacks to be invoked whenever media events, metadata
and playback status are available.
|
Modifier and Type | Field and Description |
---|---|
static int |
POSITION_SYNCHRONIZATION_CHECK
Deprecated.
The playback position synchronization mode where the RemoteControlClient instances which
expose their playback position to the framework, will be regularly polled to check
whether any drift has been noticed between their estimated position and the one they report.
|
static int |
POSITION_SYNCHRONIZATION_NONE
Deprecated.
Default playback position synchronization mode where the RemoteControlClient is not
asked regularly for its playback position to see if it has drifted from the estimated
position.
|
Constructor and Description |
---|
RemoteController(Context context,
RemoteController.OnClientUpdateListener updateListener)
Deprecated.
Class constructor.
|
RemoteController(Context context,
RemoteController.OnClientUpdateListener updateListener,
Looper looper)
Deprecated.
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
clearArtworkConfiguration()
Deprecated.
Prevents this RemoteController from receiving artwork images.
|
RemoteController.MetadataEditor |
editMetadata()
Deprecated.
Creates a
RemoteController.MetadataEditor for updating metadata values of the editable keys of
the current RemoteControlClient . |
long |
getEstimatedMediaPosition()
Deprecated.
Return the estimated playback position of the current media track or a negative value
if not available.
|
boolean |
seekTo(long timeMs)
Deprecated.
Sets the new playback position.
|
boolean |
sendMediaKeyEvent(KeyEvent keyEvent)
Deprecated.
Send a simulated key event for a media button to be received by the current client.
|
boolean |
setArtworkConfiguration(boolean wantBitmap,
int width,
int height)
Deprecated.
|
boolean |
setArtworkConfiguration(int width,
int height)
Deprecated.
Set the maximum artwork image dimensions to be received in the metadata.
|
boolean |
setSynchronizationMode(int sync)
Deprecated.
Set the playback position synchronization mode.
|
public static final int POSITION_SYNCHRONIZATION_NONE
public static final int POSITION_SYNCHRONIZATION_CHECK
public RemoteController(Context context, RemoteController.OnClientUpdateListener updateListener) throws IllegalArgumentException
context
- the Context
, must be non-null.updateListener
- the listener to be called whenever new client information is available,
must be non-null.IllegalArgumentException
public RemoteController(Context context, RemoteController.OnClientUpdateListener updateListener, Looper looper) throws IllegalArgumentException
context
- the Context
, must be non-null.updateListener
- the listener to be called whenever new client information is available,
must be non-null.looper
- the Looper
on which to run the event loop,
or null to use the current thread's looper.IllegalArgumentException
public long getEstimatedMediaPosition()
The value returned is estimated by the current process and may not be perfect.
The time returned by this method is calculated from the last state change time based
on the current play position at that time and the last known playback speed.
An application may call setSynchronizationMode(int)
to apply
a synchronization policy that will periodically re-sync the estimated position
with the RemoteControlClient.
RemoteController.OnClientUpdateListener.onClientPlaybackStateUpdate(int, long, long, float)
public boolean sendMediaKeyEvent(KeyEvent keyEvent) throws IllegalArgumentException
KeyEvent.ACTION_DOWN
action, then another event with the KeyEvent.ACTION_UP
action.
The key event will be sent to the registered receiver
(see AudioManager.registerMediaButtonEventReceiver(PendingIntent)
) whose associated
RemoteControlClient
's metadata and playback state is published (there may be
none under some circumstances).
keyEvent
- a KeyEvent
instance whose key code is one of
KeyEvent.KEYCODE_MUTE
,
KeyEvent.KEYCODE_HEADSETHOOK
,
KeyEvent.KEYCODE_MEDIA_PLAY
,
KeyEvent.KEYCODE_MEDIA_PAUSE
,
KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE
,
KeyEvent.KEYCODE_MEDIA_STOP
,
KeyEvent.KEYCODE_MEDIA_NEXT
,
KeyEvent.KEYCODE_MEDIA_PREVIOUS
,
KeyEvent.KEYCODE_MEDIA_REWIND
,
KeyEvent.KEYCODE_MEDIA_RECORD
,
KeyEvent.KEYCODE_MEDIA_FAST_FORWARD
,
KeyEvent.KEYCODE_MEDIA_CLOSE
,
KeyEvent.KEYCODE_MEDIA_EJECT
,
or KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK
.IllegalArgumentException
public boolean seekTo(long timeMs) throws IllegalArgumentException
timeMs
- a 0 or positive value for the new playback position, expressed in ms.IllegalArgumentException
public boolean setArtworkConfiguration(boolean wantBitmap, int width, int height) throws IllegalArgumentException
wantBitmap
- width
- height
- IllegalArgumentException
public boolean setArtworkConfiguration(int width, int height) throws IllegalArgumentException
width
- the maximum width in pixelsheight
- the maximum height in pixelsIllegalArgumentException
public boolean clearArtworkConfiguration()
public boolean setSynchronizationMode(int sync) throws IllegalArgumentException
sync
- POSITION_SYNCHRONIZATION_NONE
or POSITION_SYNCHRONIZATION_CHECK
IllegalArgumentException
public RemoteController.MetadataEditor editMetadata()
RemoteController.MetadataEditor
for updating metadata values of the editable keys of
the current RemoteControlClient
.
This method can only be called on a registered RemoteController.