public final class

ActionSchedule.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.test.utils.ActionSchedule.Builder

Overview

A builder for ActionSchedule instances.

Summary

Constructors
publicBuilder(java.lang.String tag)

Methods
public ActionSchedule.BuilderaddMediaSources(MediaSource mediaSources[])

Schedules a add media items action to be executed.

public ActionSchedule.Builderapply(Action action)

Schedules an action.

public ActionSchedulebuild()

Builds the schedule.

public ActionSchedule.BuilderclearMediaItems()

Schedules a clear media items action to be created.

public ActionSchedule.BuilderclearVideoSurface()

Schedules a clear video surface action.

public ActionSchedule.Builderdelay(long delayMs)

Schedules a delay between executing any previous actions and any subsequent ones.

public ActionSchedule.BuilderdisableRenderer(int index)

Schedules a renderer disable action.

public ActionSchedule.BuilderenableRenderer(int index)

Schedules a renderer enable action.

public ActionSchedule.BuilderexecuteRunnable(java.lang.Runnable runnable)

Schedules a java.lang.Runnable.

public ActionSchedule.BuildermoveMediaItem(int currentIndex, int newIndex)

Schedules a move media item action to be executed.

public ActionSchedule.Builderpause()

Schedules a pause action.

public ActionSchedule.Builderplay()

Schedules a play action.

public ActionSchedule.BuilderplayUntilPosition(int mediaItemIndex, long positionMs)

Schedules a play action, waits until the player reaches the specified position, and pauses the player again.

public ActionSchedule.BuilderplayUntilStartOfMediaItem(int mediaItemIndex)

Schedules a play action, waits until the player reaches the start of the specified media item, and pauses the player again.

public ActionSchedule.Builderprepare()

Schedules a prepare action to be executed.

public ActionSchedule.BuilderremoveMediaItem(int index)

Schedules a remove media item action to be executed.

public ActionSchedule.BuilderremoveMediaItems(int fromIndex, int toIndex)

Schedules a remove media items action to be executed.

public ActionSchedule.Builderrepeat(Action action, long intervalMs)

Schedules an action repeatedly.

public ActionSchedule.Builderseek(int mediaItemIndex, long positionMs)

Schedules a seek action.

public ActionSchedule.Builderseek(int mediaItemIndex, long positionMs, boolean catchIllegalSeekException)

Schedules a seek action to be executed.

public ActionSchedule.Builderseek(long positionMs)

Schedules a seek action.

public ActionSchedule.BuilderseekAndWait(long positionMs)

Schedules a seek action and waits until playback resumes after the seek.

public ActionSchedule.BuildersendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs)

Schedules sending a PlayerMessage.

public ActionSchedule.BuildersendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery)

Schedules to send a PlayerMessage.

public ActionSchedule.BuildersendMessage(PlayerMessage.Target target, long positionMs)

Schedules sending a PlayerMessage.

public ActionSchedule.BuildersetAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)

Schedules application of audio attributes.

public ActionSchedule.BuildersetMediaSources(boolean resetPosition, MediaSource sources[])

Schedules a set media sources action to be executed.

public ActionSchedule.BuildersetMediaSources(int mediaItemIndex, long positionMs, MediaSource sources[])

Schedules a set media source actions to be executed.

public ActionSchedule.BuildersetMediaSources(MediaSource mediaSources[])

Schedules a set media items action to be executed.

public ActionSchedule.BuildersetPlaybackParameters(PlaybackParameters playbackParameters)

Schedules a playback parameters setting action.

public ActionSchedule.BuildersetRepeatMode(int repeatMode)

Schedules a repeat mode setting action.

public ActionSchedule.BuildersetShuffleModeEnabled(boolean shuffleModeEnabled)

Schedules a shuffle setting action to be executed.

public ActionSchedule.BuildersetShuffleOrder(ShuffleOrder shuffleOrder)

Schedules a set shuffle order action to be executed.

public ActionSchedule.BuildersetVideoSurface()

Schedules a set video surface action.

public ActionSchedule.Builderstop()

Schedules a stop action.

public ActionSchedule.BuilderthrowPlaybackException(ExoPlaybackException exception)

Schedules to throw a playback exception on the playback thread.

public ActionSchedule.BuilderwaitForIsLoading(boolean targetIsLoading)

Schedules a delay until player.isLoading() changes to the specified value.

public ActionSchedule.BuilderwaitForMessage(ActionSchedule.PlayerTarget playerTarget)

Schedules a delay until a message arrives at the .

public ActionSchedule.BuilderwaitForPendingPlayerCommands()

Schedules a delay until all pending player commands have been handled.

public ActionSchedule.BuilderwaitForPlaybackState(int targetPlaybackState)

Schedules a delay until the playback state changed to the specified state.

public ActionSchedule.BuilderwaitForPlayWhenReady(boolean targetPlayWhenReady)

Schedules a delay until playWhenReady has the specified value.

public ActionSchedule.BuilderwaitForPositionDiscontinuity()

Schedules a delay until the next position discontinuity.

public ActionSchedule.BuilderwaitForTimelineChanged()

Schedules a delay until any timeline change.

public ActionSchedule.BuilderwaitForTimelineChanged(Timeline expectedTimeline, int expectedReason)

Schedules a delay until the timeline changed to a specified expected timeline.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(java.lang.String tag)

Parameters:

tag: A tag to use for logging.

Methods

public ActionSchedule.Builder delay(long delayMs)

Schedules a delay between executing any previous actions and any subsequent ones.

Parameters:

delayMs: The delay in milliseconds.

Returns:

The builder, for convenience.

public ActionSchedule.Builder apply(Action action)

Schedules an action.

Parameters:

action: The action to schedule.

Returns:

The builder, for convenience.

public ActionSchedule.Builder repeat(Action action, long intervalMs)

Schedules an action repeatedly.

Parameters:

action: The action to schedule.
intervalMs: The interval between each repetition in milliseconds.

Returns:

The builder, for convenience.

public ActionSchedule.Builder seek(long positionMs)

Schedules a seek action.

Parameters:

positionMs: The seek position.

Returns:

The builder, for convenience.

public ActionSchedule.Builder seek(int mediaItemIndex, long positionMs)

Schedules a seek action.

Parameters:

mediaItemIndex: The media item to seek to.
positionMs: The seek position.

Returns:

The builder, for convenience.

public ActionSchedule.Builder seek(int mediaItemIndex, long positionMs, boolean catchIllegalSeekException)

Schedules a seek action to be executed.

Parameters:

mediaItemIndex: The media item to seek to.
positionMs: The seek position.
catchIllegalSeekException: Whether an illegal seek position should be caught or not.

Returns:

The builder, for convenience.

public ActionSchedule.Builder seekAndWait(long positionMs)

Schedules a seek action and waits until playback resumes after the seek.

Parameters:

positionMs: The seek position.

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForPendingPlayerCommands()

Schedules a delay until all pending player commands have been handled.

A command is considered as having been handled if it arrived on the playback thread and the player acknowledged that it received the command back to the app thread.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setPlaybackParameters(PlaybackParameters playbackParameters)

Schedules a playback parameters setting action.

Parameters:

playbackParameters: The playback parameters to set.

Returns:

The builder, for convenience.

See also: Player.setPlaybackParameters(PlaybackParameters)

Schedules a stop action.

Returns:

The builder, for convenience.

Schedules a play action.

Returns:

The builder, for convenience.

public ActionSchedule.Builder playUntilPosition(int mediaItemIndex, long positionMs)

Schedules a play action, waits until the player reaches the specified position, and pauses the player again.

Parameters:

mediaItemIndex: The media item index at which the player should be paused again.
positionMs: The position in that media item at which the player should be paused again.

Returns:

The builder, for convenience.

public ActionSchedule.Builder playUntilStartOfMediaItem(int mediaItemIndex)

Schedules a play action, waits until the player reaches the start of the specified media item, and pauses the player again.

Parameters:

mediaItemIndex: The media item index at which the player should be paused again.

Returns:

The builder, for convenience.

public ActionSchedule.Builder pause()

Schedules a pause action.

Returns:

The builder, for convenience.

public ActionSchedule.Builder enableRenderer(int index)

Schedules a renderer enable action.

Returns:

The builder, for convenience.

public ActionSchedule.Builder disableRenderer(int index)

Schedules a renderer disable action.

Returns:

The builder, for convenience.

public ActionSchedule.Builder clearVideoSurface()

Schedules a clear video surface action.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setVideoSurface()

Schedules a set video surface action.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)

Schedules application of audio attributes.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setMediaSources(int mediaItemIndex, long positionMs, MediaSource sources[])

Schedules a set media source actions to be executed.

Parameters:

mediaItemIndex: The media item index to start playback from or C.INDEX_UNSET if the playback position should not be reset.
positionMs: The position in milliseconds from where playback should start. If C.TIME_UNSET is passed the default position is used. In any case, if mediaItemIndex is set to C.INDEX_UNSET the position is not reset at all and this parameter is ignored.
sources: The media sources to be set on the player.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setMediaSources(boolean resetPosition, MediaSource sources[])

Schedules a set media sources action to be executed.

Parameters:

resetPosition: Whether the playback position should be reset.
sources: The media sources to be set on the player.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setMediaSources(MediaSource mediaSources[])

Schedules a set media items action to be executed.

Parameters:

mediaSources: The media sources to add.

Returns:

The builder, for convenience.

public ActionSchedule.Builder addMediaSources(MediaSource mediaSources[])

Schedules a add media items action to be executed.

Parameters:

mediaSources: The media sources to add.

Returns:

The builder, for convenience.

public ActionSchedule.Builder moveMediaItem(int currentIndex, int newIndex)

Schedules a move media item action to be executed.

Parameters:

currentIndex: The current index of the item to move.
newIndex: The index after the item has been moved.

Returns:

The builder, for convenience.

public ActionSchedule.Builder removeMediaItem(int index)

Schedules a remove media item action to be executed.

Parameters:

index: The index of the media item to be removed.

Returns:

The builder, for convenience.

public ActionSchedule.Builder removeMediaItems(int fromIndex, int toIndex)

Schedules a remove media items action to be executed.

Parameters:

fromIndex: The start of the range of media items to be removed.
toIndex: The end of the range of media items to be removed (exclusive).

Returns:

The builder, for convenience.

public ActionSchedule.Builder prepare()

Schedules a prepare action to be executed.

Returns:

The builder, for convenience.

public ActionSchedule.Builder clearMediaItems()

Schedules a clear media items action to be created.

Returns:

The builder. for convenience,

public ActionSchedule.Builder setRepeatMode(int repeatMode)

Schedules a repeat mode setting action.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setShuffleOrder(ShuffleOrder shuffleOrder)

Schedules a set shuffle order action to be executed.

Parameters:

shuffleOrder: The shuffle order.

Returns:

The builder, for convenience.

public ActionSchedule.Builder setShuffleModeEnabled(boolean shuffleModeEnabled)

Schedules a shuffle setting action to be executed.

Returns:

The builder, for convenience.

public ActionSchedule.Builder sendMessage(PlayerMessage.Target target, long positionMs)

Schedules sending a PlayerMessage.

Parameters:

target: A message target.
positionMs: The position in the current media item at which the message should be sent, in milliseconds.

Returns:

The builder, for convenience.

public ActionSchedule.Builder sendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs)

Schedules sending a PlayerMessage.

Parameters:

target: A message target.
mediaItemIndex: The media item index at which the message should be sent.
positionMs: The position at which the message should be sent, in milliseconds.

Returns:

The builder, for convenience.

public ActionSchedule.Builder sendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery)

Schedules to send a PlayerMessage.

Parameters:

target: A message target.
mediaItemIndex: The media item index at which the message should be sent.
positionMs: The position at which the message should be sent, in milliseconds.
deleteAfterDelivery: Whether the message will be deleted after delivery.

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForTimelineChanged()

Schedules a delay until any timeline change.

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForTimelineChanged(Timeline expectedTimeline, int expectedReason)

Schedules a delay until the timeline changed to a specified expected timeline.

Parameters:

expectedTimeline: The expected timeline.
expectedReason: The expected reason of the timeline change.

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForPositionDiscontinuity()

Schedules a delay until the next position discontinuity.

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForPlayWhenReady(boolean targetPlayWhenReady)

Schedules a delay until playWhenReady has the specified value.

Parameters:

targetPlayWhenReady: The target playWhenReady value.

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForPlaybackState(int targetPlaybackState)

Schedules a delay until the playback state changed to the specified state.

Parameters:

targetPlaybackState: The target playback state.

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForIsLoading(boolean targetIsLoading)

Schedules a delay until player.isLoading() changes to the specified value.

Parameters:

targetIsLoading: The target value of player.isLoading().

Returns:

The builder, for convenience.

public ActionSchedule.Builder waitForMessage(ActionSchedule.PlayerTarget playerTarget)

Schedules a delay until a message arrives at the .

Parameters:

playerTarget: The target to observe.

Returns:

The builder, for convenience.

public ActionSchedule.Builder executeRunnable(java.lang.Runnable runnable)

Schedules a java.lang.Runnable.

Returns:

The builder, for convenience.

public ActionSchedule.Builder throwPlaybackException(ExoPlaybackException exception)

Schedules to throw a playback exception on the playback thread.

Parameters:

exception: The exception to throw.

Returns:

The builder, for convenience.

public ActionSchedule build()

Builds the schedule.