PlaybackParameters
public final class PlaybackParameters
Parameters that apply to playback, including speed setting.
Summary
Constants |
|
|---|---|
static final PlaybackParameters |
The default playback parameters: real-time playback with no silence skipping. |
Public fields |
|
|---|---|
final float |
The factor by which pitch will be shifted. |
final float |
The factor by which playback will be sped up. |
Public constructors |
|---|
PlaybackParameters(@FloatRange(from = 0, fromInclusive = false) float speed)Creates new playback parameters that set the playback speed. |
PlaybackParameters(Creates new playback parameters that set the playback speed/pitch. |
Public methods |
|
|---|---|
boolean |
|
static PlaybackParameters |
@UnstableApiRestores a |
long |
@UnstableApiReturns the media time in microseconds that will elapse in |
int |
hashCode() |
Bundle |
|
String |
toString() |
PlaybackParameters |
@UnstableApiReturns a copy with the given pitch. |
PlaybackParameters |
withSpeed(@FloatRange(from = 0, fromInclusive = false) float speed)Returns a copy with the given speed. |
Constants
DEFAULT
public static final PlaybackParameters DEFAULT
The default playback parameters: real-time playback with no silence skipping.
Public fields
Public constructors
PlaybackParameters
public PlaybackParameters(@FloatRange(from = 0, fromInclusive = false) float speed)
Creates new playback parameters that set the playback speed. The pitch of audio will not be adjusted, so the effect is to time-stretch the audio.
| Parameters | |
|---|---|
@FloatRange(from = 0, fromInclusive = false) float speed |
The factor by which playback will be sped up. Must be greater than zero. |
PlaybackParameters
public PlaybackParameters(
@FloatRange(from = 0, fromInclusive = false) float speed,
@FloatRange(from = 0, fromInclusive = false) float pitch
)
Creates new playback parameters that set the playback speed/pitch.
| Parameters | |
|---|---|
@FloatRange(from = 0, fromInclusive = false) float speed |
The factor by which playback will be sped up. Must be greater than zero. |
@FloatRange(from = 0, fromInclusive = false) float pitch |
The factor by which the pitch of audio will be adjusted. Must be greater than zero. Useful values are |
Public methods
fromBundle
@UnstableApi
public static PlaybackParameters fromBundle(Bundle bundle)
Restores a PlaybackParameters from a Bundle.
getMediaTimeUsForPlayoutTimeMs
@UnstableApi
public long getMediaTimeUsForPlayoutTimeMs(long timeMs)
Returns the media time in microseconds that will elapse in timeMs milliseconds of wallclock time.
| Parameters | |
|---|---|
long timeMs |
The time to scale, in milliseconds. |
| Returns | |
|---|---|
long |
The scaled time, in microseconds. |
withPitch
@UnstableApi
public PlaybackParameters withPitch(@FloatRange(from = 0, fromInclusive = false) float pitch)
Returns a copy with the given pitch.
| Parameters | |
|---|---|
@FloatRange(from = 0, fromInclusive = false) float pitch |
The new pitch. Must be greater than zero. |
| Returns | |
|---|---|
PlaybackParameters |
The copied playback parameters. |
withSpeed
public PlaybackParameters withSpeed(@FloatRange(from = 0, fromInclusive = false) float speed)
Returns a copy with the given speed.
| Parameters | |
|---|---|
@FloatRange(from = 0, fromInclusive = false) float speed |
The new speed. Must be greater than zero. |
| Returns | |
|---|---|
PlaybackParameters |
The copied playback parameters. |