Class ActionSchedule.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.ActionSchedule.Builder
-
- Enclosing class:
- ActionSchedule
public static final class ActionSchedule.Builder extends Object
A builder forActionSchedule
instances.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ActionSchedule.Builder
addMediaSources(MediaSource... mediaSources)
Schedules a add media items action to be executed.ActionSchedule.Builder
apply(Action action)
Schedules an action.ActionSchedule
build()
Builds the schedule.ActionSchedule.Builder
clearMediaItems()
Schedules a clear media items action to be created.ActionSchedule.Builder
clearVideoSurface()
Schedules a clear video surface action.ActionSchedule.Builder
delay(long delayMs)
Schedules a delay between executing any previous actions and any subsequent ones.ActionSchedule.Builder
disableRenderer(int index)
Schedules a renderer disable action.ActionSchedule.Builder
enableRenderer(int index)
Schedules a renderer enable action.ActionSchedule.Builder
executeRunnable(Runnable runnable)
Schedules aRunnable
.ActionSchedule.Builder
moveMediaItem(int currentIndex, int newIndex)
Schedules a move media item action to be executed.ActionSchedule.Builder
pause()
Schedules a pause action.ActionSchedule.Builder
play()
Schedules a play action.ActionSchedule.Builder
playUntilPosition(int mediaItemIndex, long positionMs)
Schedules a play action, waits until the player reaches the specified position, and pauses the player again.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.ActionSchedule.Builder
prepare()
Schedules a prepare action to be executed.ActionSchedule.Builder
removeMediaItem(int index)
Schedules a remove media item action to be executed.ActionSchedule.Builder
removeMediaItems(int fromIndex, int toIndex)
Schedules a remove media items action to be executed.ActionSchedule.Builder
repeat(Action action, long intervalMs)
Schedules an action repeatedly.ActionSchedule.Builder
seek(int mediaItemIndex, long positionMs)
Schedules a seek action.ActionSchedule.Builder
seek(int mediaItemIndex, long positionMs, boolean catchIllegalSeekException)
Schedules a seek action to be executed.ActionSchedule.Builder
seek(long positionMs)
Schedules a seek action.ActionSchedule.Builder
seekAndWait(long positionMs)
Schedules a seek action and waits until playback resumes after the seek.ActionSchedule.Builder
sendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs)
Schedules sending aPlayerMessage
.ActionSchedule.Builder
sendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery)
Schedules to send aPlayerMessage
.ActionSchedule.Builder
sendMessage(PlayerMessage.Target target, long positionMs)
Schedules sending aPlayerMessage
.ActionSchedule.Builder
setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)
Schedules application of audio attributes.ActionSchedule.Builder
setMediaSources(boolean resetPosition, MediaSource... sources)
Schedules a set media items action to be executed.ActionSchedule.Builder
setMediaSources(int mediaItemIndex, long positionMs, MediaSource... sources)
Schedules a set media items action to be executed.ActionSchedule.Builder
setMediaSources(MediaSource... mediaSources)
Schedules a set media items action to be executed.ActionSchedule.Builder
setPlaybackParameters(PlaybackParameters playbackParameters)
Schedules a playback parameters setting action.ActionSchedule.Builder
setRepeatMode(@com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Schedules a repeat mode setting action.ActionSchedule.Builder
setShuffleModeEnabled(boolean shuffleModeEnabled)
Schedules a shuffle setting action to be executed.ActionSchedule.Builder
setShuffleOrder(ShuffleOrder shuffleOrder)
Schedules a set shuffle order action to be executed.ActionSchedule.Builder
setVideoSurface()
Schedules a set video surface action.ActionSchedule.Builder
stop()
Schedules a stop action.ActionSchedule.Builder
stop(boolean reset)
Schedules a stop action.ActionSchedule.Builder
throwPlaybackException(ExoPlaybackException exception)
Schedules to throw a playback exception on the playback thread.ActionSchedule.Builder
waitForIsLoading(boolean targetIsLoading)
Schedules a delay untilplayer.isLoading()
changes to the specified value.ActionSchedule.Builder
waitForMessage(ActionSchedule.PlayerTarget playerTarget)
Schedules a delay until a message arrives at thePlayerMessage.Target
.ActionSchedule.Builder
waitForPendingPlayerCommands()
Schedules a delay until all pending player commands have been handled.ActionSchedule.Builder
waitForPlaybackState(@com.google.android.exoplayer2.Player.State int targetPlaybackState)
Schedules a delay until the playback state changed to the specified state.ActionSchedule.Builder
waitForPlayWhenReady(boolean targetPlayWhenReady)
Schedules a delay until playWhenReady has the specified value.ActionSchedule.Builder
waitForPositionDiscontinuity()
Schedules a delay until the next position discontinuity.ActionSchedule.Builder
waitForTimelineChanged()
Schedules a delay until any timeline change.ActionSchedule.Builder
waitForTimelineChanged(Timeline expectedTimeline, @com.google.android.exoplayer2.Player.TimelineChangeReason int expectedReason)
Schedules a delay until the timeline changed to a specified expected timeline.
-
-
-
Constructor Detail
-
Builder
public Builder(String tag)
- Parameters:
tag
- A tag to use for logging.
-
-
Method Detail
-
delay
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.
-
apply
public ActionSchedule.Builder apply(Action action)
Schedules an action.- Parameters:
action
- The action to schedule.- Returns:
- The builder, for convenience.
-
repeat
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.
-
seek
public ActionSchedule.Builder seek(long positionMs)
Schedules a seek action.- Parameters:
positionMs
- The seek position.- Returns:
- The builder, for convenience.
-
seek
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.
-
seek
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.
-
seekAndWait
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.
-
waitForPendingPlayerCommands
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.
-
setPlaybackParameters
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)
-
stop
public ActionSchedule.Builder stop()
Schedules a stop action.- Returns:
- The builder, for convenience.
-
stop
public ActionSchedule.Builder stop(boolean reset)
Schedules a stop action.- Parameters:
reset
- Whether the player should be reset.- Returns:
- The builder, for convenience.
-
play
public ActionSchedule.Builder play()
Schedules a play action.- Returns:
- The builder, for convenience.
-
playUntilPosition
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.
-
playUntilStartOfMediaItem
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.
-
pause
public ActionSchedule.Builder pause()
Schedules a pause action.- Returns:
- The builder, for convenience.
-
enableRenderer
public ActionSchedule.Builder enableRenderer(int index)
Schedules a renderer enable action.- Returns:
- The builder, for convenience.
-
disableRenderer
public ActionSchedule.Builder disableRenderer(int index)
Schedules a renderer disable action.- Returns:
- The builder, for convenience.
-
clearVideoSurface
public ActionSchedule.Builder clearVideoSurface()
Schedules a clear video surface action.- Returns:
- The builder, for convenience.
-
setVideoSurface
public ActionSchedule.Builder setVideoSurface()
Schedules a set video surface action.- Returns:
- The builder, for convenience.
-
setAudioAttributes
public ActionSchedule.Builder setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus)
Schedules application of audio attributes.- Returns:
- The builder, for convenience.
-
setMediaSources
public ActionSchedule.Builder setMediaSources(int mediaItemIndex, long positionMs, MediaSource... sources)
Schedules a set media items action to be executed.- Parameters:
mediaItemIndex
- The media item index to start playback from orC.INDEX_UNSET
if the playback position should not be reset.positionMs
- The position in milliseconds from where playback should start. IfC.TIME_UNSET
is passed the default position is used. In any case, ifmediaItemIndex
is set toC.INDEX_UNSET
the position is not reset at all and this parameter is ignored.- Returns:
- The builder, for convenience.
-
setMediaSources
public ActionSchedule.Builder setMediaSources(boolean resetPosition, MediaSource... sources)
Schedules a set media items action to be executed.- Parameters:
resetPosition
- Whether the playback position should be reset.- Returns:
- The builder, for convenience.
-
setMediaSources
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.
-
addMediaSources
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.
-
moveMediaItem
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.
-
removeMediaItem
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.
-
removeMediaItems
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.
-
prepare
public ActionSchedule.Builder prepare()
Schedules a prepare action to be executed.- Returns:
- The builder, for convenience.
-
clearMediaItems
public ActionSchedule.Builder clearMediaItems()
Schedules a clear media items action to be created.- Returns:
- The builder. for convenience,
-
setRepeatMode
public ActionSchedule.Builder setRepeatMode(@RepeatMode @com.google.android.exoplayer2.Player.RepeatMode int repeatMode)
Schedules a repeat mode setting action.- Returns:
- The builder, for convenience.
-
setShuffleOrder
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.
-
setShuffleModeEnabled
public ActionSchedule.Builder setShuffleModeEnabled(boolean shuffleModeEnabled)
Schedules a shuffle setting action to be executed.- Returns:
- The builder, for convenience.
-
sendMessage
public ActionSchedule.Builder sendMessage(PlayerMessage.Target target, long positionMs)
Schedules sending aPlayerMessage
.- Parameters:
positionMs
- The position in the current media item at which the message should be sent, in milliseconds.- Returns:
- The builder, for convenience.
-
sendMessage
public ActionSchedule.Builder sendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs)
Schedules sending aPlayerMessage
.- 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.
-
sendMessage
public ActionSchedule.Builder sendMessage(PlayerMessage.Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery)
Schedules to send aPlayerMessage
.- 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.
-
waitForTimelineChanged
public ActionSchedule.Builder waitForTimelineChanged()
Schedules a delay until any timeline change.- Returns:
- The builder, for convenience.
-
waitForTimelineChanged
public ActionSchedule.Builder waitForTimelineChanged(Timeline expectedTimeline, @TimelineChangeReason @com.google.android.exoplayer2.Player.TimelineChangeReason 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.
-
waitForPositionDiscontinuity
public ActionSchedule.Builder waitForPositionDiscontinuity()
Schedules a delay until the next position discontinuity.- Returns:
- The builder, for convenience.
-
waitForPlayWhenReady
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.
-
waitForPlaybackState
public ActionSchedule.Builder waitForPlaybackState(@State @com.google.android.exoplayer2.Player.State 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.
-
waitForIsLoading
public ActionSchedule.Builder waitForIsLoading(boolean targetIsLoading)
Schedules a delay untilplayer.isLoading()
changes to the specified value.- Parameters:
targetIsLoading
- The target value ofplayer.isLoading()
.- Returns:
- The builder, for convenience.
-
waitForMessage
public ActionSchedule.Builder waitForMessage(ActionSchedule.PlayerTarget playerTarget)
Schedules a delay until a message arrives at thePlayerMessage.Target
.- Parameters:
playerTarget
- The target to observe.- Returns:
- The builder, for convenience.
-
executeRunnable
public ActionSchedule.Builder executeRunnable(Runnable runnable)
Schedules aRunnable
.- Returns:
- The builder, for convenience.
-
throwPlaybackException
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.
-
build
public ActionSchedule build()
Builds the schedule.
-
-