Added in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/media/session/MediaController.TransportControls#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/media/session/MediaController.TransportControls#inhmethods)

# MediaController.TransportControls

*** ** * ** ***

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

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

<br />

*** ** * ** ***

Interface for controlling media playback on a session. This allows an app to send media transport commands to the session.

## Summary

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#fastForward()() ` Start fast forwarding. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#pause()() ` Request that the player pause its playback and stay at its current position. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#play()() ` Request that the player start its playback at its current position. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#playFromMediaId(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String mediaId, https://developer.android.com/reference/android/os/Bundle extras) ` Request that the player start playback for a specific media id. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#playFromSearch(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String query, https://developer.android.com/reference/android/os/Bundle extras) ` Request that the player start playback for a specific search query. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#playFromUri(android.net.Uri,%20android.os.Bundle)(https://developer.android.com/reference/android/net/Uri uri, https://developer.android.com/reference/android/os/Bundle extras) ` Request that the player start playback for a specific `https://developer.android.com/reference/android/net/Uri`. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#prepare()() ` Request that the player prepare its playback. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#prepareFromMediaId(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String mediaId, https://developer.android.com/reference/android/os/Bundle extras) ` Request that the player prepare playback for a specific media id. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#prepareFromSearch(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String query, https://developer.android.com/reference/android/os/Bundle extras) ` Request that the player prepare playback for a specific search query. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#prepareFromUri(android.net.Uri,%20android.os.Bundle)(https://developer.android.com/reference/android/net/Uri uri, https://developer.android.com/reference/android/os/Bundle extras) ` Request that the player prepare playback for a specific `https://developer.android.com/reference/android/net/Uri`. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#rewind()() ` Start rewinding. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#seekTo(long)(long pos) ` Move to a new location in the media stream. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#sendCustomAction(android.media.session.PlaybackState.CustomAction,%20android.os.Bundle)(https://developer.android.com/reference/android/media/session/PlaybackState.CustomAction customAction, https://developer.android.com/reference/android/os/Bundle args) ` Send a custom action back for the `https://developer.android.com/reference/android/media/session/MediaSession` to perform. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#sendCustomAction(java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/java/lang/String action, https://developer.android.com/reference/android/os/Bundle args) ` Send the id and args from a custom action back for the `https://developer.android.com/reference/android/media/session/MediaSession` to perform. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#setPlaybackSpeed(float)(float speed) ` Sets the playback speed. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#setRating(android.media.Rating)(https://developer.android.com/reference/android/media/Rating rating) ` Rate the current content. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#skipToNext()() ` Skip to the next item. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#skipToPrevious()() ` Skip to the previous item. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#skipToQueueItem(long)(long id) ` Play an item with a specific id in the play queue. |
| ` void` | ` https://developer.android.com/reference/android/media/session/MediaController.TransportControls#stop()() ` Request that the player stop its playback; it may clear its state in whatever way is appropriate. |

### 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*.

## Public methods

### fastForward

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

```
public void fastForward ()
```

Start fast forwarding. If playback is already fast forwarding this may increase the rate.

<br />

### pause

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

```
public void pause ()
```

Request that the player pause its playback and stay at its current position.

<br />

### play

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

```
public void play ()
```

Request that the player start its playback at its current position.

<br />

### playFromMediaId

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

```
public void playFromMediaId (String mediaId, 
                Bundle extras)
```

Request that the player start playback for a specific media id.

<br />

| Parameters ||
|---|---|
| `mediaId` | `String`: The id of the requested media. <br /> |
| `extras` | `Bundle`: Optional extras that can include extra information about the media item to be played. <br /> |

### playFromSearch

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

```
public void playFromSearch (String query, 
                Bundle extras)
```

Request that the player start playback for a specific search query. An empty or null query should be treated as a request to play any music.

<br />

| Parameters ||
|---|---|
| `query` | `String`: The search query. <br /> |
| `extras` | `Bundle`: Optional extras that can include extra information about the query. <br /> |

### playFromUri

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

```
public void playFromUri (Uri uri, 
                Bundle extras)
```

Request that the player start playback for a specific `https://developer.android.com/reference/android/net/Uri`.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri`: The URI of the requested media. <br /> |
| `extras` | `Bundle`: Optional extras that can include extra information about the media item to be played. <br /> |

### prepare

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

```
public void prepare ()
```

Request that the player prepare its playback. In other words, other sessions can continue to play during the preparation of this session. This method can be used to speed up the start of the playback. Once the preparation is done, the session will change its playback state to `https://developer.android.com/reference/android/media/session/PlaybackState#STATE_PAUSED`. Afterwards, `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#play()` can be called to start playback.

<br />

### prepareFromMediaId

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

```
public void prepareFromMediaId (String mediaId, 
                Bundle extras)
```

Request that the player prepare playback for a specific media id. In other words, other sessions can continue to play during the preparation of this session. This method can be used to speed up the start of the playback. Once the preparation is done, the session will change its playback state to `https://developer.android.com/reference/android/media/session/PlaybackState#STATE_PAUSED`. Afterwards, `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#play()` can be called to start playback. If the preparation is not needed, `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#playFromMediaId(java.lang.String,%20android.os.Bundle)` can be directly called without this method.

<br />

| Parameters ||
|---|---|
| `mediaId` | `String`: The id of the requested media. <br /> |
| `extras` | `Bundle`: Optional extras that can include extra information about the media item to be prepared. <br /> |

### prepareFromSearch

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

```
public void prepareFromSearch (String query, 
                Bundle extras)
```

Request that the player prepare playback for a specific search query. An empty or null query should be treated as a request to prepare any music. In other words, other sessions can continue to play during the preparation of this session. This method can be used to speed up the start of the playback. Once the preparation is done, the session will change its playback state to `https://developer.android.com/reference/android/media/session/PlaybackState#STATE_PAUSED`. Afterwards, `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#play()` can be called to start playback. If the preparation is not needed, `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#playFromSearch(java.lang.String,%20android.os.Bundle)` can be directly called without this method.

<br />

| Parameters ||
|---|---|
| `query` | `String`: The search query. <br /> |
| `extras` | `Bundle`: Optional extras that can include extra information about the query. <br /> |

### prepareFromUri

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

```
public void prepareFromUri (Uri uri, 
                Bundle extras)
```

Request that the player prepare playback for a specific `https://developer.android.com/reference/android/net/Uri`. In other words, other sessions can continue to play during the preparation of this session. This method can be used to speed up the start of the playback. Once the preparation is done, the session will change its playback state to `https://developer.android.com/reference/android/media/session/PlaybackState#STATE_PAUSED`. Afterwards, `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#play()` can be called to start playback. If the preparation is not needed, `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#playFromUri(android.net.Uri,%20android.os.Bundle)` can be directly called without this method.

<br />

| Parameters ||
|---|---|
| `uri` | `Uri`: The URI of the requested media. <br /> |
| `extras` | `Bundle`: Optional extras that can include extra information about the media item to be prepared. <br /> |

### rewind

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

```
public void rewind ()
```

Start rewinding. If playback is already rewinding this may increase the rate.

<br />

### seekTo

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

```
public void seekTo (long pos)
```

Move to a new location in the media stream.

<br />

| Parameters ||
|---|---|
| `pos` | `long`: Position to move to, in milliseconds. <br /> |

### sendCustomAction

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

```
public void sendCustomAction (PlaybackState.CustomAction customAction, 
                Bundle args)
```

Send a custom action back for the `https://developer.android.com/reference/android/media/session/MediaSession` to perform.

<br />

| Parameters ||
|---|---|
| `customAction` | `PlaybackState.CustomAction`: The action to perform. This value cannot be `null`. <br /> |
| `args` | `Bundle`: Optional arguments to supply to the `https://developer.android.com/reference/android/media/session/MediaSession` for this custom action. This value may be `null`. <br /> |

### sendCustomAction

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

```
public void sendCustomAction (String action, 
                Bundle args)
```

Send the id and args from a custom action back for the `https://developer.android.com/reference/android/media/session/MediaSession` to perform.

<br />

| Parameters ||
|---|---|
| `action` | `String`: The action identifier of the `https://developer.android.com/reference/android/media/session/PlaybackState.CustomAction` as specified by the `https://developer.android.com/reference/android/media/session/MediaSession`. This value cannot be `null`. <br /> |
| `args` | `Bundle`: Optional arguments to supply to the `https://developer.android.com/reference/android/media/session/MediaSession` for this custom action. This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/media/session/MediaController.TransportControls#sendCustomAction(android.media.session.PlaybackState.CustomAction,%20android.os.Bundle)`

### setPlaybackSpeed

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

```
public void setPlaybackSpeed (float speed)
```

Sets the playback speed. A value of `1.0f` is the default playback value, and a negative value indicates reverse playback. `0.0f` is not allowed.

<br />

| Parameters ||
|---|---|
| `speed` | `float`: The playback speed <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the `speed` is equal to zero. |

### setRating

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

```
public void setRating (Rating rating)
```

Rate the current content. This will cause the rating to be set for the current user. The Rating type must match the type returned by `https://developer.android.com/reference/android/media/session/MediaController#getRatingType()`.

<br />

| Parameters ||
|---|---|
| `rating` | `Rating`: The rating to set for the current content <br /> |

### skipToNext

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

```
public void skipToNext ()
```

Skip to the next item.

<br />

### skipToPrevious

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

```
public void skipToPrevious ()
```

Skip to the previous item.

<br />

### skipToQueueItem

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

```
public void skipToQueueItem (long id)
```

Play an item with a specific id in the play queue. If you specify an id that is not in the play queue, the behavior is undefined.

<br />

| Parameters ||
|---|---|
| `id` | `long` <br /> |

### stop

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

```
public void stop ()
```

Request that the player stop its playback; it may clear its state in whatever way is appropriate.

<br />