Added in API level 23

PlaybackParams


class PlaybackParams : Parcelable
kotlin.Any
   ↳ android.media.PlaybackParams

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

Summary

Constants
static Int

static Int

static Int

Inherited constants
Public constructors

Public methods
PlaybackParams!

Allows defaults to be returned for properties not set.

Int

Int

Retrieves the audio fallback mode.

Float

Retrieves the pitch factor.

Float

Retrieves the speed factor.

PlaybackParams!
setAudioFallbackMode(audioFallbackMode: Int)

Sets the audio fallback mode.

PlaybackParams!
setPitch(pitch: Float)

Sets the pitch factor.

PlaybackParams!
setSpeed(speed: Float)

Sets the speed factor.

Unit
writeToParcel(dest: Parcel, flags: Int)

Properties
static Parcelable.Creator<PlaybackParams!>

Constants

AUDIO_FALLBACK_MODE_DEFAULT

Added in API level 23
static val AUDIO_FALLBACK_MODE_DEFAULT: Int
Value: 0

AUDIO_FALLBACK_MODE_FAIL

Added in API level 23
static val AUDIO_FALLBACK_MODE_FAIL: Int
Value: 2

AUDIO_FALLBACK_MODE_MUTE

Added in API level 23
static val AUDIO_FALLBACK_MODE_MUTE: Int
Value: 1

Public constructors

PlaybackParams

Added in API level 23
PlaybackParams()

Public methods

allowDefaults

Added in API level 23
fun allowDefaults(): PlaybackParams!

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

Return
PlaybackParams! this PlaybackParams instance.

describeContents

Added in API level 23
fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

getAudioFallbackMode

Added in API level 23
fun getAudioFallbackMode(): Int

Retrieves the audio fallback mode.

Return
Int audio fallback mode Value is android.media.PlaybackParams#AUDIO_FALLBACK_MODE_DEFAULT, android.media.PlaybackParams#AUDIO_FALLBACK_MODE_MUTE, or android.media.PlaybackParams#AUDIO_FALLBACK_MODE_FAIL
Exceptions
java.lang.IllegalStateException if the audio fallback mode is not set.

getPitch

Added in API level 23
fun getPitch(): Float

Retrieves the pitch factor.

Return
Float pitch
Exceptions
java.lang.IllegalStateException if pitch is not set.

getSpeed

Added in API level 23
fun getSpeed(): Float

Retrieves the speed factor.

Return
Float speed
Exceptions
java.lang.IllegalStateException if speed is not set.

setAudioFallbackMode

Added in API level 23
fun setAudioFallbackMode(audioFallbackMode: Int): PlaybackParams!

Sets the audio fallback mode.

Parameters
audioFallbackMode Int: Value is android.media.PlaybackParams#AUDIO_FALLBACK_MODE_DEFAULT, android.media.PlaybackParams#AUDIO_FALLBACK_MODE_MUTE, or android.media.PlaybackParams#AUDIO_FALLBACK_MODE_FAIL
Return
PlaybackParams! this PlaybackParams instance.

setPitch

Added in API level 23
fun setPitch(pitch: Float): PlaybackParams!

Sets the pitch factor.

Parameters
pitch Float:
Return
PlaybackParams! this PlaybackParams instance.
Exceptions
java.lang.IllegalArgumentException if the pitch is negative.

setSpeed

Added in API level 23
fun setSpeed(speed: Float): PlaybackParams!

Sets the speed factor.

Parameters
speed Float:
Return
PlaybackParams! this PlaybackParams instance.

writeToParcel

Added in API level 23
fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit
Parameters
dest Parcel: The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 23
static val CREATOR: Parcelable.Creator<PlaybackParams!>