PlaybackParams
class PlaybackParams
kotlin.Any | |
↳ | androidx.media2.player.PlaybackParams |
Structure for common playback params. Used by MediaPlayer
MediaPlayer#getPlaybackParams()
and MediaPlayer#setPlaybackParams(PlaybackParams)
to control playback behavior.
PlaybackParams returned by MediaPlayer#getPlaybackParams()
will always have values. In case of MediaPlayer#setPlaybackParams
, the player will not update the param if the value is not set. For example, if pitch is set while speed is not set, only pitch will be updated.
Note that the speed value does not change the player state. For example, if MediaPlayer#getPlaybackParams()
is called with the speed of 2.0f in MediaPlayer#PLAYER_STATE_PAUSED
, the player will just update internal property and stay paused. Once MediaPlayer#play()
is called afterwards, the player will start playback with the given speed. Calling this with zero speed is not allowed.
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.IllegalArgumentException
fromAudioTrack.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
Nested classes | |
---|---|
The builder class that makes it easy to chain setters to create a |
Constants | |
---|---|
static Int | |
static Int | |
static Int |
Public methods | |
---|---|
Int? |
Returns the audio fallback mode. |
Float? |
getPitch() Returns the pitch factor. |
Float? |
getSpeed() Returns the speed factor. |
Constants
Public methods
getAudioFallbackMode
@Nullable fun getAudioFallbackMode(): Int?
Returns the audio fallback mode. null
if a value is not set.