public final class PlaybackParams extends Object implements Parcelable
AudioTrack
AudioTrack.getPlaybackParams()
and
AudioTrack.setPlaybackParams(PlaybackParams)
to control playback behavior.
audio fallback mode: select out-of-range parameter handling.
AUDIO_FALLBACK_MODE_DEFAULT
:
System will determine best handling. AUDIO_FALLBACK_MODE_MUTE
:
Play silence for params normally out of range.AUDIO_FALLBACK_MODE_FAIL
:
Return IllegalArgumentException
from
AudioTrack.setPlaybackParams(PlaybackParams)
.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:
AudioTrack.setPlaybackRate(int)
.Modifier and Type | Class and Description |
---|---|
static interface |
PlaybackParams.AudioFallbackMode |
static interface |
PlaybackParams.AudioStretchMode |
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static int |
AUDIO_FALLBACK_MODE_DEFAULT |
static int |
AUDIO_FALLBACK_MODE_FAIL |
static int |
AUDIO_FALLBACK_MODE_MUTE |
static int |
AUDIO_STRETCH_MODE_DEFAULT |
static int |
AUDIO_STRETCH_MODE_VOICE |
static Parcelable.Creator<PlaybackParams> |
CREATOR |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
PlaybackParams() |
Modifier and Type | Method and Description |
---|---|
PlaybackParams |
allowDefaults()
Allows defaults to be returned for properties not set.
|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
int |
getAudioFallbackMode()
Retrieves the audio fallback mode.
|
int |
getAudioStretchMode() |
float |
getPitch()
Retrieves the pitch factor.
|
float |
getSpeed()
Retrieves the speed factor.
|
PlaybackParams |
setAudioFallbackMode(int audioFallbackMode)
Sets the audio fallback mode.
|
PlaybackParams |
setAudioStretchMode(int audioStretchMode) |
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.
|
public static final int AUDIO_FALLBACK_MODE_DEFAULT
public static final int AUDIO_FALLBACK_MODE_MUTE
public static final int AUDIO_FALLBACK_MODE_FAIL
public static final int AUDIO_STRETCH_MODE_DEFAULT
public static final int AUDIO_STRETCH_MODE_VOICE
public static final Parcelable.Creator<PlaybackParams> CREATOR
public PlaybackParams allowDefaults()
IllegalArgumentException
exception
is raised when getting those properties
which have defaults but have never been set.PlaybackParams
instance.public PlaybackParams setAudioFallbackMode(int audioFallbackMode)
audioFallbackMode
- PlaybackParams
instance.public int getAudioFallbackMode()
IllegalStateException
- if the audio fallback mode is not set.public PlaybackParams setAudioStretchMode(int audioStretchMode)
audioStretchMode
- PlaybackParams
instance.public int getAudioStretchMode()
IllegalStateException
- if the audio stretch mode is not set.public PlaybackParams setPitch(float pitch)
pitch
- PlaybackParams
instance.InvalidArgumentException
- if the pitch is negativepublic float getPitch()
IllegalStateException
- if pitch is not set.public PlaybackParams setSpeed(float speed)
speed
- PlaybackParams
instance.public float getSpeed()
IllegalStateException
- if speed is not set.public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
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.PARCELABLE_WRITE_RETURN_VALUE
.