TestSpeedProvider


@UnstableApi
public final class TestSpeedProvider implements SpeedProvider


SpeedProvider for tests

Summary

Public methods

static TestSpeedProvider
createWithFrameCounts(
    AudioProcessor.AudioFormat audioFormat,
    int[] frameCounts,
    float[] speeds
)

Creates a TestSpeedProvider instance.

static TestSpeedProvider
createWithStartTimes(long[] startTimesUs, float[] speeds)

Creates a TestSpeedProvider instance.

long

Returns the timestamp of the next speed change, if there is any.

float
getSpeed(long timeUs)

Returns the media speed from the provided timestamp.

Public methods

createWithFrameCounts

public static TestSpeedProvider createWithFrameCounts(
    AudioProcessor.AudioFormat audioFormat,
    int[] frameCounts,
    float[] speeds
)

Creates a TestSpeedProvider instance.

Parameters
AudioProcessor.AudioFormat audioFormat

the AudioFormat.

int[] frameCounts

The frame counts for which the same speed should be applied.

float[] speeds

The speeds corresponding to each frame count. Consecutive values must be distinct.

Returns
TestSpeedProvider

A TestSpeedProvider.

createWithStartTimes

public static TestSpeedProvider createWithStartTimes(long[] startTimesUs, float[] speeds)

Creates a TestSpeedProvider instance.

Parameters
long[] startTimesUs

The speed change start times, in microseconds. The values must be distinct and in increasing order.

float[] speeds

The speeds corresponding to each start time. Consecutive values must be distinct.

Returns
TestSpeedProvider

A TestSpeedProvider.

getNextSpeedChangeTimeUs

public long getNextSpeedChangeTimeUs(long timeUs)

Returns the timestamp of the next speed change, if there is any.

Parameters
long timeUs

A timestamp, in microseconds.

Returns
long

The timestamp of the next speed change, in microseconds, or TIME_UNSET if there is no next speed change. If timeUs corresponds to a speed change, the returned value corresponds to the following speed change.

getSpeed

public float getSpeed(long timeUs)

Returns the media speed from the provided timestamp.

The media speed will stay the same until the next specified speed change.

Parameters
long timeUs

The timestamp of the media.

Returns
float

The speed that the media should be played at.