# TestPlayerRunHelper

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

*** ** * ** ***


```
@UnstableApi
class TestPlayerRunHelper
```

<br />

*** ** * ** ***

Helper methods to block the calling thread until the provided `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer` instance reaches a particular state.

This class has two usage modes:

- Fluent method chaining, e.g. `
  run(player).ignoringNonFatalErrors().untilState(STATE_ENDED)`.
- Single method call, e.g. `runUntilPlaybackState(player, STATE_ENDED)`.

New usages should prefer the fluent method chaining, and new functionality will only be added to this form. The older single methods will be kept for backwards compatibility.

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult : https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` A `https://developer.android.com/reference/kotlin/androidx/media3/transformer/CompositionPlayer` specific subclass of `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult`, giving access to conditions that only make sense for `https://developer.android.com/reference/kotlin/androidx/media3/transformer/CompositionPlayer`. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult : https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` An `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer` specific subclass of `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult`, giving access to conditions that only make sense for the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer` interface. |
| `class https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` Intermediate type that allows callers to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met. |

| ### Public functions |
|---|---|
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.transformer.CompositionPlayer)(player: https://developer.android.com/reference/kotlin/androidx/media3/transformer/CompositionPlayer!)` Entry point for a fluent "wait for condition X" assertion. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!)` Entry point for a fluent "wait for condition X" assertion. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!)` Entry point for a fluent "wait for condition X" assertion. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#play(androidx.media3.transformer.CompositionPlayer)(player: https://developer.android.com/reference/kotlin/androidx/media3/transformer/CompositionPlayer!)` Entry point for a fluent "start playback and wait for condition X" assertion. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#play(androidx.media3.exoplayer.ExoPlayer)(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!)` Entry point for a fluent "start playback and wait for condition X" assertion. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#play(androidx.media3.common.Player)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!)` Entry point for a fluent "start playback and wait for condition X" assertion. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#playUntilPosition(androidx.media3.exoplayer.ExoPlayer,int,long)(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!, mediaItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, positionMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Calls `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the specified position or an error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#playUntilStartOfMediaItem(androidx.media3.exoplayer.ExoPlayer,int)(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!, mediaItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Calls `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the start of the specified media item or a playback error occurs. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper") [run](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.exoplayer.ExoPlayer))(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult!` | `@https://checkerframework.org/api/com/google/errorprone/annotations/InlineMe.html(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper") [run](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.common.Player))(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` instead. <br /> |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlaybackException!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilError(androidx.media3.exoplayer.ExoPlayer)(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a player error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilIsLoading(androidx.media3.common.Player,boolean)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!, expectedIsLoading: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#isLoading()` matches the expected value or an error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPendingCommandsAreFullyHandled(androidx.media3.exoplayer.ExoPlayer)(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the player completely handled all previously issued commands on the internal playback thread. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPlayWhenReady(androidx.media3.common.Player,boolean)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!, expectedPlayWhenReady: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getPlayWhenReady()` matches the expected value or an error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPlaybackState(androidx.media3.common.Player,int)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.State expectedState: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getPlaybackState()` matches the expected state or an error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilPositionDiscontinuity(androidx.media3.common.Player,int)( player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!, @https://developer.android.com/reference/kotlin/androidx/media3/common/Player.DiscontinuityReason expectedReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)` is called with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.DiscontinuityReason` or an error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilRenderedFirstFrame(androidx.media3.exoplayer.ExoPlayer)(player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Listener#onRenderedFirstFrame()` is called or an error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilSleepingForOffload(androidx.media3.exoplayer.ExoPlayer,boolean)( player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!, expectedSleepForOffload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer#isSleepingForOffload()` matches the expected value, or an error occurs. |
| `java-static https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilTimelineChanged(androidx.media3.common.Player)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a timeline change or an error occurs. |
| `java-static https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#runUntilTimelineChanged(androidx.media3.common.Player,androidx.media3.common.Timeline)(player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!, expectedTimeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!)` Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getCurrentTimeline()` matches the expected timeline or an error occurs. |

## Public functions

### advance

```
java-static fun advance(player: CompositionPlayer!): TestPlayerRunHelper.CompositionPlayerRunResult!
```

Entry point for a fluent "wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

### advance

```
java-static fun advance(player: ExoPlayer!): TestPlayerRunHelper.ExoPlayerRunResult!
```

Entry point for a fluent "wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

### advance

```
java-static fun advance(player: Player!): TestPlayerRunHelper.PlayerRunResult!
```

Entry point for a fluent "wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

### play

```
java-static fun play(player: CompositionPlayer!): TestPlayerRunHelper.CompositionPlayerRunResult!
```

Entry point for a fluent "start playback and wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.CompositionPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

This is the same as `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.transformer.CompositionPlayer)` but ensures `https://developer.android.com/reference/kotlin/androidx/media3/common/BasePlayer#play()` is called before waiting in subsequent `untilXXX(...)` methods.

### play

```
java-static fun play(player: ExoPlayer!): TestPlayerRunHelper.ExoPlayerRunResult!
```

Entry point for a fluent "start playback and wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

This is the same as `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` but ensures `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#play()` is called before waiting in subsequent `untilXXX(...)` methods.

### play

```
java-static fun play(player: Player!): TestPlayerRunHelper.PlayerRunResult!
```

Entry point for a fluent "start playback and wait for condition X" assertion.

Callers can use the returned `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult` to run the main `https://developer.android.com/reference/android/os/Looper.html` until certain conditions are met.

This is the same as `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` but ensures `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#play()` is called before waiting in subsequent `untilXXX(...)` methods.

### playUntilPosition

```
java-static fun playUntilPosition(player: ExoPlayer!, mediaItemIndex: Int, positionMs: Long): Unit
```

Calls `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the specified position or an error occurs.

Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilPositionAtLeast(long)` instead if the test needs to advance the player until the publicly visible position reaches a specified value.

The playback thread is automatically blocked from making further progress after reaching this position and will only be unblocked by other `runUntil/playUntil...` methods, custom `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#runMainLooperUntil(com.google.common.base.Supplier<java.lang.Boolean>)` conditions or an explicit `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnCurrentLooper()` on the main thread.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilPosition(int,long)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `mediaItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the media item. |
| `positionMs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The position within the media item, in milliseconds. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### playUntilStartOfMediaItem

```
java-static fun playUntilStartOfMediaItem(player: ExoPlayer!, mediaItemIndex: Int): Unit
```

Calls `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#play()` then runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the internal playback thread of the `player` reaches the start of the specified media item or a playback error occurs.

Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilMediaItemIndex(int)` instead if the test needs to advance the player until the publicly visible media item index reaches a specified value.

The playback thread is automatically blocked from making further progress after reaching the media item and will only be unblocked by other `runUntil/playUntil...` methods, custom `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#runMainLooperUntil(com.google.common.base.Supplier<java.lang.Boolean>)` conditions or an explicit `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/ThreadTestUtil#unblockThreadsWaitingForProgressOnCurrentLooper()` on the main thread.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilStartOfMediaItem(int)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `mediaItemIndex: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The index of the media item. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### run

```
@InlineMe(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper")
java-static fun [run](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.exoplayer.ExoPlayer))(player: ExoPlayer!): TestPlayerRunHelper.ExoPlayerRunResult!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` instead.

### run

```
@InlineMe(replacement = "TestPlayerRunHelper.advance(player)", imports = "androidx.media3.test.utils.robolectric.TestPlayerRunHelper")
java-static fun [run](https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#run(androidx.media3.common.Player))(player: Player!): TestPlayerRunHelper.PlayerRunResult!
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` instead.

### runUntilError

```
java-static fun runUntilError(player: ExoPlayer!): ExoPlaybackException!
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a player error occurs.

Non-fatal errors are ignored.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilPlayerError()`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlaybackException!` | The raised `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlaybackException`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilIsLoading

```
java-static fun runUntilIsLoading(player: Player!, expectedIsLoading: Boolean): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#isLoading()` matches the expected value or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilLoadingIs(boolean)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `expectedIsLoading: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | The expected value for `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#isLoading()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPendingCommandsAreFullyHandled

```
java-static fun runUntilPendingCommandsAreFullyHandled(player: ExoPlayer!): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until the player completely handled all previously issued commands on the internal playback thread.

Both fatal and non-fatal errors are ignored.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!` | The `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPlayWhenReady

```
java-static fun runUntilPlayWhenReady(player: Player!, expectedPlayWhenReady: Boolean): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getPlayWhenReady()` matches the expected value or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilPlayWhenReadyIs(boolean)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `expectedPlayWhenReady: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | The expected value for `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getPlayWhenReady()`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPlaybackState

```
java-static fun runUntilPlaybackState(player: Player!, @Player.State expectedState: Int): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getPlaybackState()` matches the expected state or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilState(int)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.State expectedState: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The expected `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.State`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilPositionDiscontinuity

```
java-static fun runUntilPositionDiscontinuity(
    player: Player!,
    @Player.DiscontinuityReason expectedReason: Int
): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)` is called with the specified `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.DiscontinuityReason` or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilPositionDiscontinuityWithReason(int)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/Player.DiscontinuityReason expectedReason: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The expected `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.DiscontinuityReason`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilRenderedFirstFrame

```
java-static fun runUntilRenderedFirstFrame(player: ExoPlayer!): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player.Listener#onRenderedFirstFrame()` is called or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilFirstFrameIsRendered()`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilSleepingForOffload

```
java-static fun runUntilSleepingForOffload(
    player: ExoPlayer!,
    expectedSleepForOffload: Boolean
): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer#isSleepingForOffload()` matches the expected value, or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.exoplayer.ExoPlayer)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.ExoPlayerRunResult#untilSleepingForOffloadBecomes(boolean)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/ExoPlayer!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `expectedSleepForOffload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | The expected sleep of offload state. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilTimelineChanged

```
java-static fun runUntilTimelineChanged(player: Player!): Timeline!
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until a timeline change or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilTimelineChanges()`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | The new `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |

### runUntilTimelineChanged

```
java-static fun runUntilTimelineChanged(player: Player!, expectedTimeline: Timeline!): Unit
```

Runs tasks of the main `https://developer.android.com/reference/android/os/Looper.html` until `https://developer.android.com/reference/kotlin/androidx/media3/common/Player#getCurrentTimeline()` matches the expected timeline or an error occurs.

If a fatal `https://developer.android.com/reference/kotlin/androidx/media3/common/PlaybackException` occurs it will be thrown wrapped in an `https://developer.android.com/reference/java/lang/IllegalStateException.html`.

New usages should prefer `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper#advance(androidx.media3.common.Player)` and `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/TestPlayerRunHelper.PlayerRunResult#untilTimelineChangesTo(androidx.media3.common.Timeline)`.

| Parameters |
|---|---|
| `player: https://developer.android.com/reference/kotlin/androidx/media3/common/Player!` | The `https://developer.android.com/reference/kotlin/androidx/media3/common/Player`. |
| `expectedTimeline: https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline!` | The expected `https://developer.android.com/reference/kotlin/androidx/media3/common/Timeline`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/TimeoutException.html` | If the `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/robolectric/RobolectricUtil#DEFAULT_TIMEOUT_MS()` is exceeded. |