belongs to Maven artifact androidx.media2:media2:1.0.0-alpha01

PlaybackParams2

public final class PlaybackParams2
extends Object

java.lang.Object
   ↳ androidx.media2.PlaybackParams2


Structure for common playback params. Used by MediaPlayer2 MediaPlayer2.getPlaybackParams() and MediaPlayer2.setPlaybackParams(PlaybackParams2) to control playback behavior.

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 AudioTrack.setPlaybackRate(int).

Summary

Nested classes

class PlaybackParams2.Builder

The builder class that makes it easy to chain setters to create a PlaybackParams2 object. 

Constants

int AUDIO_FALLBACK_MODE_DEFAULT

int AUDIO_FALLBACK_MODE_FAIL

int AUDIO_FALLBACK_MODE_MUTE

Public methods

Integer getAudioFallbackMode()

Returns the audio fallback mode.

Float getPitch()

Returns the pitch factor.

Float getSpeed()

Returns the speed factor.

Inherited methods

Constants

AUDIO_FALLBACK_MODE_DEFAULT

public static final int AUDIO_FALLBACK_MODE_DEFAULT

Constant Value: 0 (0x00000000)

AUDIO_FALLBACK_MODE_FAIL

public static final int AUDIO_FALLBACK_MODE_FAIL

Constant Value: 2 (0x00000002)

AUDIO_FALLBACK_MODE_MUTE

public static final int AUDIO_FALLBACK_MODE_MUTE

Constant Value: 1 (0x00000001)

Public methods

getAudioFallbackMode

public Integer getAudioFallbackMode ()

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

Returns
Integer

getPitch

public Float getPitch ()

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

Returns
Float

getSpeed

public Float getSpeed ()

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

Returns
Float