# DefaultLivePlaybackSpeedControl

# DefaultLivePlaybackSpeedControl

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

*** ** * ** ***

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

<br />

```
@UnstableApi
class DefaultLivePlaybackSpeedControl : LivePlaybackSpeedControl
```

<br />

*** ** * ** ***

A[LivePlaybackSpeedControl](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/LivePlaybackSpeedControl)that adjusts the playback speed using a proportional controller.

The control mechanism calculates the adjusted speed as`1.0 + proportionalControlFactor
x (currentLiveOffsetSec - targetLiveOffsetSec)`. Unit speed (1.0f) is used, if the`
currentLiveOffsetSec`is closer to`targetLiveOffsetSec`than the value set with[setMaxLiveOffsetErrorMsForUnitSpeed](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setMaxLiveOffsetErrorMsForUnitSpeed(long)).

The resulting speed is clamped to a minimum and maximum speed defined by the media, the fallback values set with[setFallbackMinPlaybackSpeed](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setFallbackMinPlaybackSpeed(float))and[setFallbackMaxPlaybackSpeed](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setFallbackMaxPlaybackSpeed(float))or the[minimum](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_FALLBACK_MIN_PLAYBACK_SPEED())and[maximum](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED())fallback default values.

When the player rebuffers, the target live offset[is increased](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setTargetLiveOffsetIncrementOnRebufferMs(long))to adjust to the reduced network capabilities. The live playback speed control also[keeps track](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setMinPossibleLiveOffsetSmoothingFactor(float))of the minimum possible live offset to decrease the target live offset again if conditions improve. The minimum possible live offset is derived from the current offset and the duration of buffered media.

## Summary

|                                                                                                                                                       ### Nested types                                                                                                                                                        |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `class `[DefaultLivePlaybackSpeedControl.Builder](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder) Builder for a[DefaultLivePlaybackSpeedControl](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl). |

|                                      ### Constants                                      |
|-----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED())` = 1.03f` The default maximum factor by which playback can be sped up that should be used if no maximum playback speed is defined by the media.                                                                                           |
| `const `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [DEFAULT_FALLBACK_MIN_PLAYBACK_SPEED](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_FALLBACK_MIN_PLAYBACK_SPEED())` = 0.97f` The default minimum factor by which playback can be sped up that should be used if no minimum playback speed is defined by the media.                                                                                           |
| `const `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)   | [DEFAULT_MAX_LIVE_OFFSET_ERROR_MS_FOR_UNIT_SPEED](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_MAX_LIVE_OFFSET_ERROR_MS_FOR_UNIT_SPEED())` = 20` The default maximum difference between the current live offset and the target live offset, in milliseconds, for which unit speed (1.0f) is used.                                                           |
| `const `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [DEFAULT_MIN_POSSIBLE_LIVE_OFFSET_SMOOTHING_FACTOR](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_MIN_POSSIBLE_LIVE_OFFSET_SMOOTHING_FACTOR())` = 0.999f` The default smoothing factor when smoothing the minimum possible live offset that can be achieved during playback.                                                                                 |
| `const `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)   | [DEFAULT_MIN_UPDATE_INTERVAL_MS](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_MIN_UPDATE_INTERVAL_MS())` = 1000` The default[minimum interval](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setMinUpdateIntervalMs(long))between playback speed changes, in milliseconds.               |
| `const `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [DEFAULT_PROPORTIONAL_CONTROL_FACTOR](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_PROPORTIONAL_CONTROL_FACTOR())` = 0.1f` The default[proportional control factor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setProportionalControlFactor(float))used to adjust the playback speed. |
| `const `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)   | [DEFAULT_TARGET_LIVE_OFFSET_INCREMENT_ON_REBUFFER_MS](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#DEFAULT_TARGET_LIVE_OFFSET_INCREMENT_ON_REBUFFER_MS())` = 500` The default increment applied to the target live offset each time the player is rebuffering, in milliseconds                                                                                      |

|                              ### Public functions                               |
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [getAdjustedPlaybackSpeed](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#getAdjustedPlaybackSpeed(long,long))`(liveOffsetUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, bufferedDurationUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Returns the adjusted playback speed in order get closer towards the[target live offset](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/LivePlaybackSpeedControl#getTargetLiveOffsetUs()). |
| [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)   | [getTargetLiveOffsetUs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#getTargetLiveOffsetUs())`()` Returns the current target live offset, in microseconds, or[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())if no target live offset is defined for the current media.                                                                                                                                                                                                              |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)   | [notifyRebuffer](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#notifyRebuffer())`()` Notifies the live playback speed control that a rebuffer occurred.                                                                                                                                                                                                                                                                                                                                                                                 |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)   | [setLiveConfiguration](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#setLiveConfiguration(androidx.media3.common.MediaItem.LiveConfiguration))`(liveConfiguration: `[MediaItem.LiveConfiguration](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LiveConfiguration)`!)` Sets the live configuration defined by the media.                                                                                                                                                                              |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)   | [setTargetLiveOffsetOverrideUs](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl#setTargetLiveOffsetOverrideUs(long))`(liveOffsetUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Sets the target live offset in microseconds that overrides the live offset[configured](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/LivePlaybackSpeedControl#setLiveConfiguration(androidx.media3.common.MediaItem.LiveConfiguration))by the media.                                     |

## Constants

### DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED

```
const val DEFAULT_FALLBACK_MAX_PLAYBACK_SPEED = 1.03f: Float
```

The default maximum factor by which playback can be sped up that should be used if no maximum playback speed is defined by the media.  

### DEFAULT_FALLBACK_MIN_PLAYBACK_SPEED

```
const val DEFAULT_FALLBACK_MIN_PLAYBACK_SPEED = 0.97f: Float
```

The default minimum factor by which playback can be sped up that should be used if no minimum playback speed is defined by the media.  

### DEFAULT_MAX_LIVE_OFFSET_ERROR_MS_FOR_UNIT_SPEED

```
const val DEFAULT_MAX_LIVE_OFFSET_ERROR_MS_FOR_UNIT_SPEED = 20: Long
```

The default maximum difference between the current live offset and the target live offset, in milliseconds, for which unit speed (1.0f) is used.  

### DEFAULT_MIN_POSSIBLE_LIVE_OFFSET_SMOOTHING_FACTOR

```
const val DEFAULT_MIN_POSSIBLE_LIVE_OFFSET_SMOOTHING_FACTOR = 0.999f: Float
```

The default smoothing factor when smoothing the minimum possible live offset that can be achieved during playback.  

### DEFAULT_MIN_UPDATE_INTERVAL_MS

```
const val DEFAULT_MIN_UPDATE_INTERVAL_MS = 1000: Long
```

The default[minimum interval](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setMinUpdateIntervalMs(long))between playback speed changes, in milliseconds.  

### DEFAULT_PROPORTIONAL_CONTROL_FACTOR

```
const val DEFAULT_PROPORTIONAL_CONTROL_FACTOR = 0.1f: Float
```

The default[proportional control factor](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.Builder#setProportionalControlFactor(float))used to adjust the playback speed.  

### DEFAULT_TARGET_LIVE_OFFSET_INCREMENT_ON_REBUFFER_MS

```
const val DEFAULT_TARGET_LIVE_OFFSET_INCREMENT_ON_REBUFFER_MS = 500: Long
```

The default increment applied to the target live offset each time the player is rebuffering, in milliseconds  

## Public functions

### getAdjustedPlaybackSpeed

```
fun getAdjustedPlaybackSpeed(liveOffsetUs: Long, bufferedDurationUs: Long): Float
```

Returns the adjusted playback speed in order get closer towards the[target live offset](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/LivePlaybackSpeedControl#getTargetLiveOffsetUs()).  

|                                             Parameters                                              |
|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| `liveOffsetUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)       | The current live offset, in microseconds.                         |
| `bufferedDurationUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The duration of media that's currently buffered, in microseconds. |

|                                     Returns                                     |
|---------------------------------------------------------------------------------|----------------------------------------------------------|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | The adjusted factor by which playback should be sped up. |

### getTargetLiveOffsetUs

```
fun getTargetLiveOffsetUs(): Long
```

Returns the current target live offset, in microseconds, or[TIME_UNSET](https://developer.android.com/reference/kotlin/androidx/media3/common/C#TIME_UNSET())if no target live offset is defined for the current media.  

### notifyRebuffer

```
fun notifyRebuffer(): Unit
```

Notifies the live playback speed control that a rebuffer occurred.

A rebuffer is defined to be caused by buffer depletion rather than a user action. Hence this method is not called during initial buffering or when buffering as a result of a seek operation.  

### setLiveConfiguration

```
fun setLiveConfiguration(liveConfiguration: MediaItem.LiveConfiguration!): Unit
```

Sets the live configuration defined by the media.  

|                                                                        Parameters                                                                        |
|----------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `liveConfiguration: `[MediaItem.LiveConfiguration](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LiveConfiguration)`!` | The[LiveConfiguration](https://developer.android.com/reference/kotlin/androidx/media3/common/MediaItem.LiveConfiguration)as defined by the media. |

### setTargetLiveOffsetOverrideUs

```
fun setTargetLiveOffsetOverrideUs(liveOffsetUs: Long): Unit
```

Sets the target live offset in microseconds that overrides the live offset[configured](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/LivePlaybackSpeedControl#setLiveConfiguration(androidx.media3.common.MediaItem.LiveConfiguration))by the media. Passing`C.TIME_UNSET`deletes a previous override.

If no target live offset is configured by[setLiveConfiguration](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/LivePlaybackSpeedControl#setLiveConfiguration(androidx.media3.common.MediaItem.LiveConfiguration)), this override has no effect.