PlaybackParams

Added in 1.0.0
Deprecated in 1.3.0

public final class PlaybackParams


Structure for common playback params.

Used by MediaPlayergetPlaybackParams and setPlaybackParams to control playback behavior.

PlaybackParams returned by getPlaybackParams will always have values. In case of setPlaybackParams, the player will not update the param if the value is not set. For example, if pitch is set while speed is not set, only pitch will be updated.

Note that the speed value does not change the player state. For example, if getPlaybackParams is called with the speed of 2.0f in PLAYER_STATE_PAUSED, the player will just update internal property and stay paused. Once play is called afterwards, the player will start playback with the given speed. Calling this with zero speed is not allowed.

audio fallback mode: select out-of-range parameter handling.

pitch: increases or decreases the tonal frequency of the audio content. It is expressed as a multiplicative factor, where normal pitch is 1.0f.

speed: increases or decreases the time to play back a set of audio or video frames. It is expressed as a multiplicative factor, where normal speed is 1.0f.

Different combinations of speed and pitch may be used for audio playback; some common ones:

  • Pitch equals 1.0f. Speed change will be done with pitch preserved, often called timestretching.
  • Pitch equals speed. Speed change will be done by resampling, similar to setPlaybackRate.

Summary

Nested types

public final class PlaybackParams.Builder

This class is deprecated.

androidx.media2 is deprecated.

Constants

static final int
static final int
static final int

Public methods

@Nullable Integer

Returns the audio fallback mode.

@Nullable Float

Returns the pitch factor.

@Nullable Float

Returns the speed factor.

Constants

AUDIO_FALLBACK_MODE_DEFAULT

Added in 1.0.0
Deprecated in 1.3.0
public static final int AUDIO_FALLBACK_MODE_DEFAULT = 0

AUDIO_FALLBACK_MODE_FAIL

Added in 1.0.0
Deprecated in 1.3.0
public static final int AUDIO_FALLBACK_MODE_FAIL = 2

AUDIO_FALLBACK_MODE_MUTE

Added in 1.0.0
Deprecated in 1.3.0
public static final int AUDIO_FALLBACK_MODE_MUTE = 1

Public methods

getAudioFallbackMode

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Integer getAudioFallbackMode()

Returns the audio fallback mode. null if a value is not set.

getPitch

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Float getPitch()

Returns the pitch factor. null if a value is not set.

getSpeed

Added in 1.0.0
Deprecated in 1.3.0
public @Nullable Float getSpeed()

Returns the speed factor. null if a value is not set.