@UnstableApi
class TestPlayerRunHelper


Helper methods to block the calling thread until the provided ExoPlayer instance reaches a particular state.

Summary

Public functions

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

Calls play, runs tasks of the main Looper until the player reaches the specified position or a playback error occurs.

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

Calls play, runs tasks of the main Looper until the player reaches the specified media item or a playback error occurs.

java-static ExoPlaybackException!

Runs tasks of the main Looper until a player error occurs.

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

Runs tasks of the main Looper until isLoading matches the expected value or a playback error occurs.

java-static Unit

Runs tasks of the main Looper until the player completely handled all previously issued commands on the internal playback thread.

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

Runs tasks of the main Looper until getPlayWhenReady matches the expected value or a playback error occurs.

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

Runs tasks of the main Looper until getPlaybackState matches the expected state or a playback error occurs.

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

Runs tasks of the main Looper until onPositionDiscontinuity is called with the specified Player.DiscontinuityReason or a playback error occurs.

java-static Unit

Runs tasks of the main Looper until the onRenderedFirstFrame callback is called or a playback error occurs.

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

Runs tasks of the main Looper until onSleepingForOffloadChanged is called or a playback error occurs.

java-static Timeline!

Runs tasks of the main Looper until a timeline change or a playback error occurs.

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

Runs tasks of the main Looper until getCurrentTimeline matches the expected timeline or a playback error occurs.

Public functions

playUntilPosition

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

Calls play, runs tasks of the main Looper until the player reaches the specified position or a playback error occurs.

The playback thread is automatically blocked from making further progress after reaching this position and will only be unblocked by other run/playUntil... methods, custom runMainLooperUntil conditions or an explicit unblockThreadsWaitingForProgressOnCurrentLooper on the main thread.

If a playback error occurs it will be thrown wrapped in an IllegalStateException.

Parameters
player: ExoPlayer!

The Player.

mediaItemIndex: Int

The index of the media item.

positionMs: Long

The position within the media item, in milliseconds.

playUntilStartOfMediaItem

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

Calls play, runs tasks of the main Looper until the player reaches the specified media item or a playback error occurs.

The playback thread is automatically blocked from making further progress after reaching the media item and will only be unblocked by other run/playUntil... methods, custom runMainLooperUntil conditions or an explicit unblockThreadsWaitingForProgressOnCurrentLooper on the main thread.

If a playback error occurs it will be thrown wrapped in an IllegalStateException.

Parameters
player: ExoPlayer!

The Player.

mediaItemIndex: Int

The index of the media item.

runUntilError

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

Runs tasks of the main Looper until a player error occurs.

Parameters
player: ExoPlayer!

The Player.

runUntilIsLoading

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

Runs tasks of the main Looper until 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: Player!

The Player.

expectedIsLoading: Boolean

The expected value for isLoading.

runUntilPendingCommandsAreFullyHandled

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

Runs tasks of the main Looper until the player completely handled all previously issued commands on the internal playback thread.

Parameters
player: ExoPlayer!

The Player.

runUntilPlayWhenReady

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

Runs tasks of the main Looper until 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: Player!

The Player.

expectedPlayWhenReady: Boolean

The expected value for getPlayWhenReady.

runUntilPlaybackState

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

Runs tasks of the main Looper until 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: Player!

The Player.

@Player.State expectedState: Int

The expected Player.State.

runUntilPositionDiscontinuity

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

Runs tasks of the main Looper until onPositionDiscontinuity 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: Player!

The Player.

@Player.DiscontinuityReason expectedReason: Int

The expected Player.DiscontinuityReason.

runUntilRenderedFirstFrame

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

Runs tasks of the main Looper until the onRenderedFirstFrame callback is called or a playback error occurs.

If a playback error occurs it will be thrown wrapped in an IllegalStateException..

Parameters
player: ExoPlayer!

The Player.

runUntilSleepingForOffload

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

Runs tasks of the main Looper until onSleepingForOffloadChanged is called or a playback error occurs.

If a playback error occurs it will be thrown wrapped in an IllegalStateException.

Parameters
player: ExoPlayer!

The Player.

expectedSleepForOffload: Boolean

The expected sleep of offload state.

runUntilTimelineChanged

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

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: Player!

The Player.

Returns
Timeline!

The new Timeline.

runUntilTimelineChanged

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

Runs tasks of the main Looper until 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: Player!

The Player.

expectedTimeline: Timeline!

The expected Timeline.