# SpeedProvider

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

*** ** * ** ***


```
@UnstableApi
public interface SpeedProvider
```

<br />

Known direct subclasses [TestSpeedProvider](https://developer.android.com/reference/androidx/media3/test/utils/TestSpeedProvider)

|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/TestSpeedProvider` | `https://developer.android.com/reference/androidx/media3/common/audio/SpeedProvider` for tests |

*** ** * ** ***

A custom interface that determines the speed for media at specific timestamps.

## Summary

| ### Constants |
|---|---|
| `default static final https://developer.android.com/reference/androidx/media3/common/audio/SpeedProvider` | `https://developer.android.com/reference/androidx/media3/common/audio/SpeedProvider#DEFAULT()` A speed provider with default values. |

| ### Public methods |
|---|---|
| `abstract long` | `https://developer.android.com/reference/androidx/media3/common/audio/SpeedProvider#getNextSpeedChangeTimeUs(long)(long timeUs)` Returns the timestamp of the next speed change, if there is any. |
| `abstract float` | `https://developer.android.com/reference/androidx/media3/common/audio/SpeedProvider#getSpeed(long)(long timeUs)` Returns the media speed from the provided timestamp. |

## Constants

### DEFAULT

```
default static final SpeedProvider DEFAULT
```

A speed provider with default values.

## Public methods

### getNextSpeedChangeTimeUs

```
abstract 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 `https://developer.android.com/reference/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

```
abstract float getSpeed(long timeUs)
```

Returns the media speed from the provided timestamp.

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

| Parameters |
|---|---|
| `long timeUs` | The timestamp of the media. |

| Returns |
|---|---|
| `float` | The speed that the media should be played at. |