Back to Exoplayer

ActionSchedule.Builder (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/testutil/ActionSchedule.Builder.html

latest26.5 KB
Original Source

Package com.google.android.exoplayer2.testutil

Class ActionSchedule.Builder


public static final classActionSchedule.Builderextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")

A builder for ActionSchedule instances.

Constructor Summary

Constructors | Constructor | Description | | --- | --- | | Builder​(String tag) | |

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 a Runnable. | | 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 a PlayerMessage. | | ActionSchedule.Builder | sendMessage​(PlayerMessage.Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery) | Schedules to send a PlayerMessage. | | ActionSchedule.Builder | sendMessage​(PlayerMessage.Target target, long positionMs) | Schedules sending a PlayerMessage. | | ActionSchedule.Builder | setAudioAttributes​(AudioAttributes audioAttributes, boolean handleAudioFocus) | Schedules application of audio attributes. | | ActionSchedule.Builder | setMediaSources​(boolean resetPosition, MediaSource... sources) | Schedules a set media sources action to be executed. | | ActionSchedule.Builder | setMediaSources​(int mediaItemIndex, long positionMs, MediaSource... sources) | Schedules a set media source actions 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 | throwPlaybackException​(ExoPlaybackException exception) | Schedules to throw a playback exception on the playback thread. | | ActionSchedule.Builder | waitForIsLoading​(boolean targetIsLoading) | Schedules a delay until player.isLoading() changes to the specified value. | | ActionSchedule.Builder | waitForMessage​(ActionSchedule.PlayerTarget playerTarget) | Schedules a delay until a message arrives at the PlayerMessage.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. |

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

- 

Builder

public Builder​([String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")tag)

Parameters:tag - A tag to use for logging.

Method Detail

- 

delay

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")apply​([Action](Action.html "class in com.google.android.exoplayer2.testutil")action)

Schedules an action. Parameters:action - The action to schedule.Returns:The builder, for convenience.

- 

repeat

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")repeat​([Action](Action.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")seek​(long positionMs)

Schedules a seek action. Parameters:positionMs - The seek position.Returns:The builder, for convenience.

- 

seek

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setPlaybackParameters​([PlaybackParameters](../PlaybackParameters.html "class in com.google.android.exoplayer2")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")stop()

Schedules a stop action. Returns:The builder, for convenience.

- 

play

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")play()

Schedules a play action. Returns:The builder, for convenience.

- 

playUntilPosition

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")pause()

Schedules a pause action. Returns:The builder, for convenience.

- 

enableRenderer

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")enableRenderer​(int index)

Schedules a renderer enable action. Returns:The builder, for convenience.

- 

disableRenderer

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")disableRenderer​(int index)

Schedules a renderer disable action. Returns:The builder, for convenience.

- 

clearVideoSurface

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")clearVideoSurface()

Schedules a clear video surface action. Returns:The builder, for convenience.

- 

setVideoSurface

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setVideoSurface()

Schedules a set video surface action. Returns:The builder, for convenience.

- 

setAudioAttributes

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setAudioAttributes​([AudioAttributes](../audio/AudioAttributes.html "class in com.google.android.exoplayer2.audio")audioAttributes,
                                                 boolean handleAudioFocus)

Schedules application of audio attributes. Returns:The builder, for convenience.

- 

setMediaSources

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setMediaSources​(int mediaItemIndex,
                                              long positionMs,[MediaSource](../source/MediaSource.html "interface in com.google.android.exoplayer2.source")... 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.

- 

setMediaSources

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setMediaSources​(boolean resetPosition,[MediaSource](../source/MediaSource.html "interface in com.google.android.exoplayer2.source")... 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.

- 

setMediaSources

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setMediaSources​([MediaSource](../source/MediaSource.html "interface in com.google.android.exoplayer2.source")... mediaSources)

Schedules a set media items action to be executed. Parameters:mediaSources - The media sources to add.Returns:The builder, for convenience.

- 

addMediaSources

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")addMediaSources​([MediaSource](../source/MediaSource.html "interface in com.google.android.exoplayer2.source")... mediaSources)

Schedules a add media items action to be executed. Parameters:mediaSources - The media sources to add.Returns:The builder, for convenience.

- 

moveMediaItem

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")prepare()

Schedules a prepare action to be executed. Returns:The builder, for convenience.

- 

clearMediaItems

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")clearMediaItems()

Schedules a clear media items action to be created. Returns:The builder. for convenience,

- 

setRepeatMode

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setRepeatMode​([@RepeatMode](../Player.RepeatMode.html "annotation in com.google.android.exoplayer2")@com.google.android.exoplayer2.Player.RepeatMode int repeatMode)

Schedules a repeat mode setting action. Returns:The builder, for convenience.

- 

setShuffleOrder

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setShuffleOrder​([ShuffleOrder](../source/ShuffleOrder.html "interface in com.google.android.exoplayer2.source")shuffleOrder)

Schedules a set shuffle order action to be executed. Parameters:shuffleOrder - The shuffle order.Returns:The builder, for convenience.

- 

setShuffleModeEnabled

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")setShuffleModeEnabled​(boolean shuffleModeEnabled)

Schedules a shuffle setting action to be executed. Returns:The builder, for convenience.

- 

sendMessage

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")sendMessage​([PlayerMessage.Target](../PlayerMessage.Target.html "interface in com.google.android.exoplayer2")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.

- 

sendMessage

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")sendMessage​([PlayerMessage.Target](../PlayerMessage.Target.html "interface in com.google.android.exoplayer2")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.

- 

sendMessage

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")sendMessage​([PlayerMessage.Target](../PlayerMessage.Target.html "interface in com.google.android.exoplayer2")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.

- 

waitForTimelineChanged

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")waitForTimelineChanged()

Schedules a delay until any timeline change. Returns:The builder, for convenience.

- 

waitForTimelineChanged

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")waitForTimelineChanged​([Timeline](../Timeline.html "class in com.google.android.exoplayer2")expectedTimeline,[@TimelineChangeReason](../Player.TimelineChangeReason.html "annotation in com.google.android.exoplayer2")@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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")waitForPositionDiscontinuity()

Schedules a delay until the next position discontinuity. Returns:The builder, for convenience.

- 

waitForPlayWhenReady

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")waitForPlayWhenReady​(boolean targetPlayWhenReady)

Schedules a delay until playWhenReady has the specified value. Parameters:targetPlayWhenReady - The target playWhenReady value.Returns:The builder, for convenience.

- 

waitForPlaybackState

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")waitForPlaybackState​([@State](../Player.State.html "annotation in com.google.android.exoplayer2")@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

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")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.

- 

waitForMessage

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")waitForMessage​([ActionSchedule.PlayerTarget](ActionSchedule.PlayerTarget.html "class in com.google.android.exoplayer2.testutil")playerTarget)

Schedules a delay until a message arrives at the PlayerMessage.Target. Parameters:playerTarget - The target to observe.Returns:The builder, for convenience.

- 

executeRunnable

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")executeRunnable​([Runnable](https://developer.android.com/reference/java/lang/Runnable.html "class or interface in java.lang")runnable)

Schedules a Runnable. Returns:The builder, for convenience.

- 

throwPlaybackException

@CanIgnoreReturnValue
public[ActionSchedule.Builder](ActionSchedule.Builder.html "class in com.google.android.exoplayer2.testutil")throwPlaybackException​([ExoPlaybackException](../ExoPlaybackException.html "class in com.google.android.exoplayer2")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](ActionSchedule.html "class in com.google.android.exoplayer2.testutil")build()

Builds the schedule.