Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)   
Deprecated in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Nested Classes](https://developer.android.com/reference/android/media/RemoteController#nestedclasses) \| [Constants](https://developer.android.com/reference/android/media/RemoteController#constants) \| [Ctors](https://developer.android.com/reference/android/media/RemoteController#pubctors) \| [Methods](https://developer.android.com/reference/android/media/RemoteController#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/RemoteController#inhmethods)

# RemoteController

*** ** * ** ***

` public final class RemoteController `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.media.RemoteController |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 21.**   

Use `https://developer.android.com/reference/android/media/session/MediaController` instead.

The RemoteController class is used to control media playback, display and update media metadata and playback status, published by applications using the `https://developer.android.com/reference/android/media/RemoteControlClient` class.

A RemoteController shall be registered through `https://developer.android.com/reference/android/media/AudioManager#registerRemoteController(android.media.RemoteController)` in order for the system to send media event updates to the `https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener` listener set in the class constructor. Implement the methods of the interface to receive the information published by the active `https://developer.android.com/reference/android/media/RemoteControlClient` instances.   

By default an `https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener` implementation will not receive bitmaps for album art. Use `https://developer.android.com/reference/android/media/RemoteController#setArtworkConfiguration(int,%20int)` to receive images as well.

Registration requires the `https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener` listener to be one of the enabled notification listeners (see `https://developer.android.com/reference/android/service/notification/NotificationListenerService`).

## Summary

| ### Nested classes ||
|---|---|
| ` class` | `https://developer.android.com/reference/android/media/RemoteController.MetadataEditor` A class to read the metadata published by a `https://developer.android.com/reference/android/media/RemoteControlClient`, or send a `https://developer.android.com/reference/android/media/RemoteControlClient` new values for keys that can be edited. |
| ` interface` | `https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener` Interface definition for the callbacks to be invoked whenever media events, metadata and playback status are available. |

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/media/RemoteController#POSITION_SYNCHRONIZATION_CHECK` 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. |
| `int` | `https://developer.android.com/reference/android/media/RemoteController#POSITION_SYNCHRONIZATION_NONE` 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. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/media/RemoteController#RemoteController(android.content.Context,%20android.media.RemoteController.OnClientUpdateListener)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener updateListener) ` Class constructor. |
| ` https://developer.android.com/reference/android/media/RemoteController#RemoteController(android.content.Context,%20android.media.RemoteController.OnClientUpdateListener,%20android.os.Looper)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener updateListener, https://developer.android.com/reference/android/os/Looper looper) ` Class constructor. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/android/media/RemoteController#clearArtworkConfiguration()() ` Prevents this RemoteController from receiving artwork images. |
| ` https://developer.android.com/reference/android/media/RemoteController.MetadataEditor` | ` https://developer.android.com/reference/android/media/RemoteController#editMetadata()() ` Creates a `https://developer.android.com/reference/android/media/RemoteController.MetadataEditor` for updating metadata values of the editable keys of the current `https://developer.android.com/reference/android/media/RemoteControlClient`. |
| ` long` | ` https://developer.android.com/reference/android/media/RemoteController#getEstimatedMediaPosition()() ` Return the estimated playback position of the current media track or a negative value if not available. |
| ` boolean` | ` https://developer.android.com/reference/android/media/RemoteController#seekTo(long)(long timeMs) ` Sets the new playback position. |
| ` boolean` | ` https://developer.android.com/reference/android/media/RemoteController#sendMediaKeyEvent(android.view.KeyEvent)(https://developer.android.com/reference/android/view/KeyEvent keyEvent) ` Send a simulated key event for a media button to be received by the current client. |
| ` boolean` | ` https://developer.android.com/reference/android/media/RemoteController#setArtworkConfiguration(int,%20int)(int width, int height) ` Set the maximum artwork image dimensions to be received in the metadata. |
| ` boolean` | ` https://developer.android.com/reference/android/media/RemoteController#setSynchronizationMode(int)(int sync) ` Set the playback position synchronization mode. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### POSITION_SYNCHRONIZATION_CHECK

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int POSITION_SYNCHRONIZATION_CHECK
```

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. Note that this mode should only ever be used when needing to display very accurate playback position, as regularly polling a RemoteControlClient for its position may have an impact on battery life (if applicable) when this query will trigger network transactions in the case of remote playback.

<br />

Constant Value: 1 (0x00000001)

### POSITION_SYNCHRONIZATION_NONE

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int POSITION_SYNCHRONIZATION_NONE
```

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.

<br />

Constant Value: 0 (0x00000000)

## Public constructors

### RemoteController

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public RemoteController (Context context, 
                RemoteController.OnClientUpdateListener updateListener)
```

Class constructor.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the `https://developer.android.com/reference/android/content/Context`, must be non-null. <br /> |
| `updateListener` | `RemoteController.OnClientUpdateListener`: the listener to be called whenever new client information is available, must be non-null. <br /> |

| Throws ||
|---|---|
|   | java.lang.IllegalArgumentException |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` |   |

### RemoteController

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public RemoteController (Context context, 
                RemoteController.OnClientUpdateListener updateListener, 
                Looper looper)
```

Class constructor.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: the `https://developer.android.com/reference/android/content/Context`, must be non-null. <br /> |
| `updateListener` | `RemoteController.OnClientUpdateListener`: the listener to be called whenever new client information is available, must be non-null. <br /> |
| `looper` | `Looper`: the `https://developer.android.com/reference/android/os/Looper` on which to run the event loop, or null to use the current thread's looper. <br /> |

| Throws ||
|---|---|
|   | java.lang.IllegalArgumentException |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` |   |

## Public methods

### clearArtworkConfiguration

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean clearArtworkConfiguration ()
```

Prevents this RemoteController from receiving artwork images.

<br />

| Returns ||
|---|---|
| `boolean` | true if receiving artwork images was successfully disabled. <br /> |

### editMetadata

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public RemoteController.MetadataEditor editMetadata ()
```

Creates a `https://developer.android.com/reference/android/media/RemoteController.MetadataEditor` for updating metadata values of the editable keys of the current `https://developer.android.com/reference/android/media/RemoteControlClient`. This method can only be called on a registered RemoteController.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/media/RemoteController.MetadataEditor` | a new MetadataEditor instance. <br /> |

### getEstimatedMediaPosition

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getEstimatedMediaPosition ()
```

Return the estimated playback position of the current media track or a negative value if not available.

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 `https://developer.android.com/reference/android/media/RemoteController#setSynchronizationMode(int)` to apply a synchronization policy that will periodically re-sync the estimated position with the RemoteControlClient.

<br />

<br />

| Returns ||
|---|---|
| `long` | the current estimated playback position in milliseconds or a negative value if not available <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/RemoteController.OnClientUpdateListener#onClientPlaybackStateUpdate(int,%20long,%20long,%20float)`

### seekTo

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean seekTo (long timeMs)
```

Sets the new playback position. This method can only be called on a registered RemoteController.

<br />

| Parameters ||
|---|---|
| `timeMs` | `long`: a 0 or positive value for the new playback position, expressed in ms. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the command to set the playback position was successfully sent. <br /> |

| Throws ||
|---|---|
|   | java.lang.IllegalArgumentException |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` |   |

### sendMediaKeyEvent

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean sendMediaKeyEvent (KeyEvent keyEvent)
```

Send a simulated key event for a media button to be received by the current client. To simulate a key press, you must first send a KeyEvent built with a `https://developer.android.com/reference/android/view/KeyEvent#ACTION_DOWN` action, then another event with the `https://developer.android.com/reference/android/view/KeyEvent#ACTION_UP` action.

The key event will be sent to the registered receiver (see `https://developer.android.com/reference/android/media/AudioManager#registerMediaButtonEventReceiver(android.app.PendingIntent)`) whose associated `https://developer.android.com/reference/android/media/RemoteControlClient`'s metadata and playback state is published (there may be none under some circumstances).

<br />

| Parameters ||
|---|---|
| `keyEvent` | `KeyEvent`: a media session `https://developer.android.com/reference/android/view/KeyEvent`, as defined by `https://developer.android.com/reference/android/view/KeyEvent#isMediaSessionKey(int)`. <br /> |

| Returns ||
|---|---|
| `boolean` | true if the event was successfully sent, false otherwise. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | If the provided `https://developer.android.com/reference/android/view/KeyEvent` is not a media session key, as defined by `https://developer.android.com/reference/android/view/KeyEvent#isMediaSessionKey(int)`. |

### setArtworkConfiguration

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean setArtworkConfiguration (int width, 
                int height)
```

Set the maximum artwork image dimensions to be received in the metadata. No bitmaps will be received unless this has been specified.

<br />

| Parameters ||
|---|---|
| `width` | `int`: the maximum width in pixels <br /> |
| `height` | `int`: the maximum height in pixels <br /> |

| Returns ||
|---|---|
| `boolean` | true if the artwork dimension was successfully set. <br /> |

| Throws ||
|---|---|
|   | java.lang.IllegalArgumentException |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` |   |

### setSynchronizationMode

Added in [API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean setSynchronizationMode (int sync)
```

Set the playback position synchronization mode. Must be called on a registered RemoteController.

<br />

| Parameters ||
|---|---|
| `sync` | `int`: `https://developer.android.com/reference/android/media/RemoteController#POSITION_SYNCHRONIZATION_NONE` or `https://developer.android.com/reference/android/media/RemoteController#POSITION_SYNCHRONIZATION_CHECK` <br /> |

| Returns ||
|---|---|
| `boolean` | true if the synchronization mode was successfully set. <br /> |

| Throws ||
|---|---|
|   | java.lang.IllegalArgumentException |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` |   |