# TestSpeedProvider

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/TestSpeedProvider.java+class:androidx.media3.test.utils.TestSpeedProvider)

*** ** * ** ***

<br />

```
@UnstableApi
class TestSpeedProvider : SpeedProvider
```

<br />

*** ** * ** ***

`https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider` for tests

## Summary

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider#createWithFrameCounts(androidx.media3.common.audio.AudioProcessor.AudioFormat,int[],float[])( audioFormat: https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessor.AudioFormat!, frameCounts: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, speeds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>! )` Creates a `TestSpeedProvider` instance. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider#createWithStartTimes(long[],float[])( startTimesUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!, speeds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>! )` Creates a `TestSpeedProvider` instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider#getNextSpeedChangeTimeUs(long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the timestamp of the next speed change, if there is any. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider#getSpeed(long)(timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Returns the media speed from the provided timestamp. |

### Inherited Constants

From [androidx.media3.common.audio.SpeedProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider) `const https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider!` `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider#DEFAULT()`

A speed provider with default values.

## Public functions

### createWithFrameCounts

```
java-static fun createWithFrameCounts(
    audioFormat: AudioProcessor.AudioFormat!,
    frameCounts: IntArray<Int>!,
    speeds: FloatArray<Float>!
): TestSpeedProvider!
```

Creates a `TestSpeedProvider` instance.

| Parameters |
|---|---|
| `audioFormat: https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessor.AudioFormat!` | the `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/AudioProcessor.AudioFormat`. |
| `frameCounts: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | The frame counts for which the same speed should be applied. |
| `speeds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>!` | The speeds corresponding to each frame count. Consecutive values must be distinct. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider!` | A `TestSpeedProvider`. |

### createWithStartTimes

```
java-static fun createWithStartTimes(
    startTimesUs: LongArray<Long>!,
    speeds: FloatArray<Float>!
): TestSpeedProvider!
```

Creates a `TestSpeedProvider` instance.

| Parameters |
|---|---|
| `startTimesUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | The speed change start times, in microseconds. The values must be distinct and in increasing order. |
| `speeds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html>!` | The speeds corresponding to each start time. Consecutive values must be distinct. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider!` | A `TestSpeedProvider`. |

### getNextSpeedChangeTimeUs

```
fun getNextSpeedChangeTimeUs(timeUs: Long): Long
```

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

| Parameters |
|---|---|
| `timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | A timestamp, in microseconds. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The timestamp of the next speed change, in microseconds, or `https://developer.android.com/reference/kotlin/androidx/media3/common/C#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

```
fun getSpeed(timeUs: Long): Float
```

Returns the media speed from the provided timestamp.

The media speed will stay the same until `https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider#getNextSpeedChangeTimeUs(long)`.

| Parameters |
|---|---|
| `timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The timestamp of the media. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The speed that the media should be played at. |