Android APIs
public final class

PlaybackParams

extends Object
implements Parcelable
java.lang.Object
   ↳ android.media.PlaybackParams

Class Overview

Structure for common playback params. Used by AudioTrack getPlaybackParams() and setPlaybackParams(PlaybackParams) 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 setPlaybackRate(int).

Summary

Constants
int AUDIO_FALLBACK_MODE_DEFAULT
int AUDIO_FALLBACK_MODE_FAIL
int AUDIO_FALLBACK_MODE_MUTE
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<PlaybackParams> CREATOR
Public Constructors
PlaybackParams()
Public Methods
PlaybackParams allowDefaults()
Allows defaults to be returned for properties not set.
int describeContents()
Describe the kinds of special objects contained in this Parcelable's marshalled representation.
int getAudioFallbackMode()
Retrieves the audio fallback mode.
float getPitch()
Retrieves the pitch factor.
float getSpeed()
Retrieves the speed factor.
PlaybackParams setAudioFallbackMode(int audioFallbackMode)
Sets the audio fallback mode.
PlaybackParams setPitch(float pitch)
Sets the pitch factor.
PlaybackParams setSpeed(float speed)
Sets the speed factor.
void writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final int AUDIO_FALLBACK_MODE_DEFAULT

Added in API level 23

Constant Value: 0 (0x00000000)

public static final int AUDIO_FALLBACK_MODE_FAIL

Added in API level 23

Constant Value: 2 (0x00000002)

public static final int AUDIO_FALLBACK_MODE_MUTE

Added in API level 23

Constant Value: 1 (0x00000001)

Fields

public static final Creator<PlaybackParams> CREATOR

Added in API level 23

Public Constructors

public PlaybackParams ()

Added in API level 23

Public Methods

public PlaybackParams allowDefaults ()

Added in API level 23

Allows defaults to be returned for properties not set. Otherwise a IllegalArgumentException exception is raised when getting those properties which have defaults but have never been set.

Returns
  • this PlaybackParams instance.

public int describeContents ()

Added in API level 23

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Returns
  • a bitmask indicating the set of special object types marshalled by the Parcelable.

public int getAudioFallbackMode ()

Added in API level 23

Retrieves the audio fallback mode.

Returns
  • audio fallback mode
Throws
IllegalStateException if the audio fallback mode is not set.

public float getPitch ()

Added in API level 23

Retrieves the pitch factor.

Returns
  • pitch
Throws
IllegalStateException if pitch is not set.

public float getSpeed ()

Added in API level 23

Retrieves the speed factor.

Returns
  • speed
Throws
IllegalStateException if speed is not set.

public PlaybackParams setAudioFallbackMode (int audioFallbackMode)

Added in API level 23

Sets the audio fallback mode.

Returns
  • this PlaybackParams instance.

public PlaybackParams setPitch (float pitch)

Added in API level 23

Sets the pitch factor.

Returns
  • this PlaybackParams instance.
Throws
if the pitch is negative

public PlaybackParams setSpeed (float speed)

Added in API level 23

Sets the speed factor.

Returns
  • this PlaybackParams instance.

public void writeToParcel (Parcel dest, int flags)

Added in API level 23

Flatten this object in to a Parcel.

Parameters
dest The Parcel in which the object should be written.
flags Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE.