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(
    @FloatRange(from = 0, fromInclusive = false) float speed,
    @FloatRange(from = 0, fromInclusive = false) float pitch
)

Creates new playback parameters that set the playback speed/pitch.

Public methods

boolean
static PlaybackParameters

Restores a PlaybackParameters from a Bundle.

long

Returns the media time in microseconds that will elapse in timeMs milliseconds of wallclock time.

int
Bundle
String
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

pitch

public final float pitch

The factor by which pitch will be shifted.

speed

public final float speed

The factor by which playback will be sped up.

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 1 (to time-stretch audio) and the same value as passed in as the speed (to resample audio, which is useful for slow-motion videos).

Public methods

equals

public boolean equals(@Nullable Object obj)

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.

hashCode

public int hashCode()

toBundle

@UnstableApi
public Bundle toBundle()

toString

public String toString()

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.