# StuckPlayerDetector

# StuckPlayerDetector

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/util/StuckPlayerDetector.java+class:androidx.media3.common.util.StuckPlayerDetector)

*** ** * ** ***

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

<br />

```
@UnstableApi
class StuckPlayerDetector
```

<br />

*** ** * ** ***

A utility class to detect whether a[Player](https://developer.android.com/reference/kotlin/androidx/media3/common/Player)is stuck.

The class must be used on the thread associated with the[getApplicationLooper](https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getApplicationLooper()).

## Summary

|                                                                                           ### Nested types                                                                                           |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interface `[StuckPlayerDetector.Callback](https://developer.android.com/reference/kotlin/androidx/media3/common/util/StuckPlayerDetector.Callback) Callback notified when the player appears stuck. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ### Public constructors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [StuckPlayerDetector](https://developer.android.com/reference/kotlin/androidx/media3/common/util/StuckPlayerDetector#StuckPlayerDetector(androidx.media3.common.Player,androidx.media3.common.util.StuckPlayerDetector.Callback,androidx.media3.common.util.Clock,int,int,int,int))`(` ` player: `[Player](https://developer.android.com/reference/kotlin/androidx/media3/common/Player)`!,` ` callback: `[StuckPlayerDetector.Callback](https://developer.android.com/reference/kotlin/androidx/media3/common/util/StuckPlayerDetector.Callback)`!,` ` clock: `[Clock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock)`!,` ` stuckBufferingTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` stuckPlayingTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` stuckPlayingNotEndingTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` stuckSuppressedTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Creates the stuck player detector. |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [release](https://developer.android.com/reference/kotlin/androidx/media3/common/util/StuckPlayerDetector#release())`()` Releases the stuck player detector. |

## Public constructors

### StuckPlayerDetector

```
StuckPlayerDetector(
    player: Player!,
    callback: StuckPlayerDetector.Callback!,
    clock: Clock!,
    stuckBufferingTimeoutMs: Int,
    stuckPlayingTimeoutMs: Int,
    stuckPlayingNotEndingTimeoutMs: Int,
    stuckSuppressedTimeoutMs: Int
)
```

Creates the stuck player detector.

Must be called on the player's[getApplicationLooper](https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getApplicationLooper()).  

|                                                                       Parameters                                                                       |
|--------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------|
| `player: `[Player](https://developer.android.com/reference/kotlin/androidx/media3/common/Player)`!`                                                    | The[Player](https://developer.android.com/reference/kotlin/androidx/media3/common/Player)to monitor.                                                |
| `callback: `[StuckPlayerDetector.Callback](https://developer.android.com/reference/kotlin/androidx/media3/common/util/StuckPlayerDetector.Callback)`!` | The[Callback](https://developer.android.com/reference/kotlin/androidx/media3/common/util/StuckPlayerDetector.Callback)to notify of stuck playbacks. |
| `clock: `[Clock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock)`!`                                                  | The[Clock](https://developer.android.com/reference/kotlin/androidx/media3/common/util/Clock).                                                       |
| `stuckBufferingTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                 | The timeout after which the player is assumed stuck buffering if it's buffering and no loading progress is made, in milliseconds.                   |
| `stuckPlayingTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                   | The timeout after which the player is assumed stuck playing if it's playing and no position progress is made, in milliseconds.                      |
| `stuckPlayingNotEndingTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                          | The timeout after which the player is assumed stuck playing if it's playing and it should have ended, in milliseconds.                              |
| `stuckSuppressedTimeoutMs: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                | The timeout after which the player is assumed stuck in a suppression state, in milliseconds.                                                        |

## Public functions

### release

```
fun release(): Unit
```

Releases the stuck player detector.