PlaybackParams

Added in 1.0.0
Deprecated in 1.3.0

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

This class is deprecated.

androidx.media2 is deprecated.

Public functions

Int?

Returns the audio fallback mode.

Float?

Returns the pitch factor.

Float?

Returns the speed factor.

Constants

AUDIO_FALLBACK_MODE_DEFAULT

Added in 1.0.0
Deprecated in 1.3.0
const val AUDIO_FALLBACK_MODE_DEFAULT = 0: Int

AUDIO_FALLBACK_MODE_FAIL

Added in 1.0.0
Deprecated in 1.3.0
const val AUDIO_FALLBACK_MODE_FAIL = 2: Int

AUDIO_FALLBACK_MODE_MUTE

Added in 1.0.0
Deprecated in 1.3.0
const val AUDIO_FALLBACK_MODE_MUTE = 1: Int

Public functions

getAudioFallbackMode

Added in 1.0.0
Deprecated in 1.3.0
fun getAudioFallbackMode(): Int?

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

getPitch

Added in 1.0.0
Deprecated in 1.3.0
fun getPitch(): Float?

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

getSpeed

Added in 1.0.0
Deprecated in 1.3.0
fun getSpeed(): Float?

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