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.
-
PlaybackParams.AUDIO_FALLBACK_MODE_DEFAULT: System will determine best handling. -
PlaybackParams.AUDIO_FALLBACK_MODE_MUTE: Play silence for params normally out of range. -
PlaybackParams.AUDIO_FALLBACK_MODE_FAIL: Returnjava.lang.IllegalArgumentExceptionfromAudioTrack.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:
- 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 |
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
| Int |
Retrieves the audio fallback mode. |
| Float |
getPitch()Retrieves the pitch factor. |
| Float |
getSpeed()Retrieves the speed factor. |
| PlaybackParams! |
setAudioFallbackMode(audioFallbackMode: Int)Sets the audio fallback mode. |
| PlaybackParams! |
Sets the pitch factor. |
| PlaybackParams! |
Sets the speed factor. |
| Unit |
writeToParcel(dest: Parcel, flags: Int)Flatten this object in to a Parcel. |
| Properties | |
|---|---|
| static Parcelable.Creator<PlaybackParams!> | |
Constants
AUDIO_FALLBACK_MODE_DEFAULT
static val AUDIO_FALLBACK_MODE_DEFAULT: Int
Value: 0Public constructors
Public methods
allowDefaults
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
fun describeContents(): Int
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel,int), the return value of this method must include the CONTENTS_FILE_DESCRIPTOR bit.
| Return | |
|---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or
|
getAudioFallbackMode
fun getAudioFallbackMode(): Int
Retrieves the audio fallback mode.
| Return | |
|---|---|
Int |
audio fallback mode. Value is one of the following: |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if the audio fallback mode is not set. |
getPitch
fun getPitch(): Float
Retrieves the pitch factor.
| Return | |
|---|---|
Float |
pitch |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if pitch is not set. |
getSpeed
fun getSpeed(): Float
Retrieves the speed factor.
| Return | |
|---|---|
Float |
speed |
| Exceptions | |
|---|---|
java.lang.IllegalStateException |
if speed is not set. |
setAudioFallbackMode
fun setAudioFallbackMode(audioFallbackMode: Int): PlaybackParams!
Sets the audio fallback mode.
| Parameters | |
|---|---|
audioFallbackMode |
Int: Value is one of the following: |
| Return | |
|---|---|
PlaybackParams! |
this PlaybackParams instance. |
setPitch
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
fun setSpeed(speed: Float): PlaybackParams!
Sets the speed factor.
| Parameters | |
|---|---|
speed |
Float: |
| Return | |
|---|---|
PlaybackParams! |
this PlaybackParams instance. |
writeToParcel
fun writeToParcel(
dest: Parcel,
flags: Int
): Unit
Flatten this object in to a Parcel.
| 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 the following:
|