# PlaybackParameters

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/PlaybackParameters.java+class:androidx.media3.common.PlaybackParameters)

*** ** * ** ***


```
public final class PlaybackParameters
```

<br />

*** ** * ** ***

Parameters that apply to playback, including speed setting.

## Summary

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#DEFAULT()` The default playback parameters: real-time playback with no silence skipping. |

| ### Public fields |
|---|---|
| `final float` | `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#pitch()` The factor by which pitch will be shifted. |
| `final float` | `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#speed()` The factor by which playback will be sped up. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#PlaybackParameters(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float speed)` Creates new playback parameters that set the playback speed. |
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#PlaybackParameters(float,float)( @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float speed, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float pitch )` Creates new playback parameters that set the playback speed/pitch. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html obj)` |
| `static https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#fromBundle(android.os.Bundle)(https://developer.android.com/reference/android/os/Bundle.html bundle)` Restores a `PlaybackParameters` from a `https://developer.android.com/reference/android/os/Bundle.html`. |
| `long` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#getMediaTimeUsForPlayoutTimeMs(long)(long timeMs)` Returns the media time in microseconds that will elapse in `timeMs` milliseconds of wallclock time. |
| `int` | `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#hashCode()()` |
| `https://developer.android.com/reference/android/os/Bundle.html` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#toBundle()()` |
| `https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#toString()()` |
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | `@https://developer.android.com/reference/androidx/media3/common/util/UnstableApi https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#withPitch(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float pitch)` Returns a copy with the given pitch. |
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters#withSpeed(float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float speed)` Returns a copy with the given speed. |

## Constants

### DEFAULT

```
public static final PlaybackParameters DEFAULT
```

The default playback parameters: real-time playback with no silence skipping.

## Public fields

### pitch

```
public final float pitch
```

The factor by which pitch will be shifted.

### speed

```
public final float speed
```

The factor by which playback will be sped up.

## Public constructors

### PlaybackParameters

```
public PlaybackParameters(@FloatRange(from = 0, fromInclusive = false) float speed)
```

Creates new playback parameters that set the playback speed. The pitch of audio will not be adjusted, so the effect is to time-stretch the audio.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float speed` | The factor by which playback will be sped up. Must be greater than zero. |

### PlaybackParameters

```
public PlaybackParameters(
    @FloatRange(from = 0, fromInclusive = false) float speed,
    @FloatRange(from = 0, fromInclusive = false) float pitch
)
```

Creates new playback parameters that set the playback speed/pitch.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float speed` | The factor by which playback will be sped up. Must be greater than zero. |
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float pitch` | The factor by which the pitch of audio will be adjusted. Must be greater than zero. Useful values are `1` (to time-stretch audio) and the same value as passed in as the `speed` (to resample audio, which is useful for slow-motion videos). |

## Public methods

### equals

```
public boolean equals(@Nullable Object obj)
```

### fromBundle

```
@UnstableApi
public static PlaybackParameters fromBundle(Bundle bundle)
```

Restores a `PlaybackParameters` from a `https://developer.android.com/reference/android/os/Bundle.html`.

### getMediaTimeUsForPlayoutTimeMs

```
@UnstableApi
public long getMediaTimeUsForPlayoutTimeMs(long timeMs)
```

Returns the media time in microseconds that will elapse in `timeMs` milliseconds of wallclock time.

| Parameters |
|---|---|
| `long timeMs` | The time to scale, in milliseconds. |

| Returns |
|---|---|
| `long` | The scaled time, in microseconds. |

### hashCode

```
public int hashCode()
```

### toBundle

```
@UnstableApi
public Bundle toBundle()
```

### toString

```
public String toString()
```

### withPitch

```
@UnstableApi
public PlaybackParameters withPitch(@FloatRange(from = 0, fromInclusive = false) float pitch)
```

Returns a copy with the given pitch.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float pitch` | The new pitch. Must be greater than zero. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | The copied playback parameters. |

### withSpeed

```
public PlaybackParameters withSpeed(@FloatRange(from = 0, fromInclusive = false) float speed)
```

Returns a copy with the given speed.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0, fromInclusive = false) float speed` | The new speed. Must be greater than zero. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/PlaybackParameters` | The copied playback parameters. |