# SpeedProvider

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/common/audio/SpeedProvider "View this page in Java")

<br />

```
@UnstableApi
interface SpeedProvider
```

<br />

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

|------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|
| [TestSpeedProvider](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/TestSpeedProvider) | [SpeedProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider)for tests |

*** ** * ** ***

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

## Summary

|                                                     ### Constants                                                     |
|-----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[SpeedProvider](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider)`!` | [DEFAULT](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider#DEFAULT()) A speed provider with default values. |

|                              ### Public functions                               |
|---------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)   | [getNextSpeedChangeTimeUs](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider#getNextSpeedChangeTimeUs(long))`(timeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Returns the timestamp of the next speed change, if there is any. |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [getSpeed](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider#getSpeed(long))`(timeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Returns the media speed from the provided timestamp.                                             |

## Constants

### DEFAULT

```
const val DEFAULT: SpeedProvider!
```

A speed provider with default values.  

## Public functions

### getNextSpeedChangeTimeUs

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

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

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

|                                    Returns                                    |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The timestamp of the next speed change, in microseconds, or[TIME_UNSET](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[the next specified speed change](https://developer.android.com/reference/kotlin/androidx/media3/common/audio/SpeedProvider#getNextSpeedChangeTimeUs(long)).  

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

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