docs/doc/reference/com/google/android/exoplayer2/robolectric/TestPlayerRunHelper.html
Package com.google.android.exoplayer2.robolectric
public classTestPlayerRunHelperextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Helper methods to block the calling thread until the provided ExoPlayer instance reaches a particular state.
All Methods Static Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| static void | playUntilPosition(ExoPlayer player, int mediaItemIndex, long positionMs) |
Calls Player.play(), runs tasks of the main Looper until the player reaches the specified position or a playback error occurs, and then pauses the player.
|
| static void | playUntilStartOfMediaItem(ExoPlayer player, int mediaItemIndex) |
Calls Player.play(), runs tasks of the main Looper until the player reaches the specified media item or a playback error occurs, and then pauses the player.
|
| static ExoPlaybackException | runUntilError(ExoPlayer player) |
Runs tasks of the main Looper until a player error occurs.
|
| static void | runUntilIsLoading(Player player, boolean expectedIsLoading) |
Runs tasks of the main Looper until Player.isLoading() matches the expected value or a playback error occurs.
|
| static void | runUntilPendingCommandsAreFullyHandled(ExoPlayer player) |
Runs tasks of the main Looper until the player completely handled all previously issued commands on the internal playback thread.
|
| static void | runUntilPlaybackState(Player player, @com.google.android.exoplayer2.Player.State int expectedState) |
Runs tasks of the main Looper until Player.getPlaybackState() matches the expected state or a playback error occurs.
|
| static void | runUntilPlayWhenReady(Player player, boolean expectedPlayWhenReady) |
Runs tasks of the main Looper until Player.getPlayWhenReady() matches the expected value or a playback error occurs.
|
| static void | runUntilPositionDiscontinuity(Player player, @com.google.android.exoplayer2.Player.DiscontinuityReason int expectedReason) |
Runs tasks of the main Looper until Player.Listener.onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int) is called with the specified Player.DiscontinuityReason or a playback error occurs.
|
| static void | runUntilRenderedFirstFrame(ExoPlayer player) |
Runs tasks of the main Looper until the Player.Listener.onRenderedFirstFrame() callback is called or a playback error occurs.
|
| static void | runUntilSleepingForOffload(ExoPlayer player, boolean expectedSleepForOffload) |
Runs tasks of the main Looper until ExoPlayer.AudioOffloadListener.onExperimentalSleepingForOffloadChanged(boolean) is called or a playback error occurs.
|
| static Timeline | runUntilTimelineChanged(Player player) |
Runs tasks of the main Looper until a timeline change or a playback error occurs.
|
| static void | runUntilTimelineChanged(Player player, Timeline expectedTimeline) |
Runs tasks of the main Looper until Player.getCurrentTimeline() matches the expected timeline or a playback error occurs.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static void runUntilPlaybackState([Player](../Player.html "interface in com.google.android.exoplayer2")player,[@State](../Player.State.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.Player.State int expectedState)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until Player.getPlaybackState() matches the expected state or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.expectedState - The expected Player.State.Throws:TimeoutException - If the default timeout is exceeded.
-
public static void runUntilPlayWhenReady([Player](../Player.html "interface in com.google.android.exoplayer2")player,
boolean expectedPlayWhenReady)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until Player.getPlayWhenReady() matches the expected value or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.expectedPlayWhenReady - The expected value for Player.getPlayWhenReady().Throws:TimeoutException - If the default timeout is exceeded.
-
public static void runUntilIsLoading([Player](../Player.html "interface in com.google.android.exoplayer2")player,
boolean expectedIsLoading)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until Player.isLoading() matches the expected value or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.expectedIsLoading - The expected value for Player.isLoading().Throws:TimeoutException - If the default timeout is exceeded.
-
public static void runUntilTimelineChanged([Player](../Player.html "interface in com.google.android.exoplayer2")player,[Timeline](../Timeline.html "class in com.google.android.exoplayer2")expectedTimeline)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until Player.getCurrentTimeline() matches the expected timeline or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.expectedTimeline - The expected Timeline.Throws:TimeoutException - If the default timeout is exceeded.
-
public static[Timeline](../Timeline.html "class in com.google.android.exoplayer2")runUntilTimelineChanged([Player](../Player.html "interface in com.google.android.exoplayer2")player)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until a timeline change or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.Returns:The new Timeline.Throws:TimeoutException - If the default timeout is exceeded.
-
public static void runUntilPositionDiscontinuity([Player](../Player.html "interface in com.google.android.exoplayer2")player,[@DiscontinuityReason](../Player.DiscontinuityReason.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.Player.DiscontinuityReason int expectedReason)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until Player.Listener.onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int) is called with the specified Player.DiscontinuityReason or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.expectedReason - The expected Player.DiscontinuityReason.Throws:TimeoutException - If the default timeout is exceeded.
-
public static[ExoPlaybackException](../ExoPlaybackException.html "class in com.google.android.exoplayer2")runUntilError([ExoPlayer](../ExoPlayer.html "interface in com.google.android.exoplayer2")player)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until a player error occurs.
Parameters:player - The Player.Returns:The raised ExoPlaybackException.Throws:TimeoutException - If the default timeout is exceeded.
-
public static void runUntilSleepingForOffload([ExoPlayer](../ExoPlayer.html "interface in com.google.android.exoplayer2")player,
boolean expectedSleepForOffload)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until ExoPlayer.AudioOffloadListener.onExperimentalSleepingForOffloadChanged(boolean) is called or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.expectedSleepForOffload - The expected sleep of offload state.Throws:TimeoutException - If the default timeout is exceeded.
-
public static void runUntilRenderedFirstFrame([ExoPlayer](../ExoPlayer.html "interface in com.google.android.exoplayer2")player)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until the Player.Listener.onRenderedFirstFrame() callback is called or a playback error occurs.
If a playback error occurs it will be thrown wrapped in an IllegalStateException..
Parameters:player - The Player.Throws:TimeoutException - If the default timeout is exceeded.
-
public static void playUntilPosition([ExoPlayer](../ExoPlayer.html "interface in com.google.android.exoplayer2")player,
int mediaItemIndex,
long positionMs)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Calls Player.play(), runs tasks of the main Looper until the player reaches the specified position or a playback error occurs, and then pauses the player.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.mediaItemIndex - The index of the media item.positionMs - The position within the media item, in milliseconds.Throws:TimeoutException - If the default timeout is exceeded.
-
public static void playUntilStartOfMediaItem([ExoPlayer](../ExoPlayer.html "interface in com.google.android.exoplayer2")player,
int mediaItemIndex)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Calls Player.play(), runs tasks of the main Looper until the player reaches the specified media item or a playback error occurs, and then pauses the player.
If a playback error occurs it will be thrown wrapped in an IllegalStateException.
Parameters:player - The Player.mediaItemIndex - The index of the media item.Throws:TimeoutException - If the default timeout is exceeded.
-
public static void runUntilPendingCommandsAreFullyHandled([ExoPlayer](../ExoPlayer.html "interface in com.google.android.exoplayer2")player)
throws[TimeoutException](https://developer.android.com/reference/java/util/concurrent/TimeoutException.html "class or interface in java.util.concurrent")
Runs tasks of the main Looper until the player completely handled all previously issued commands on the internal playback thread.
Parameters:player - The Player.Throws:TimeoutException - If the default timeout is exceeded.