Package com.google.android.exoplayer2.testutil

## 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 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 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 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 tag)

      Parameters:
        `tag` - A tag to use for logging.

  - ### Method Detail

    - #### delay

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          public ActionSchedule.Builder apply​(Action action)

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

    - #### repeat

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          public ActionSchedule.Builder seek​(long positionMs)

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

    - #### seek

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          public ActionSchedule.Builder stop()

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

    - #### stop

          @CanIgnoreReturnValue
          public ActionSchedule.Builder stop​(boolean reset)

      Schedules a stop action.
      Parameters:
        `reset` - Whether the player should be reset.
      Returns:
        The builder, for convenience.

    - #### play

          @CanIgnoreReturnValue
          public ActionSchedule.Builder play()

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

    - #### playUntilPosition

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          public ActionSchedule.Builder pause()

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

    - #### enableRenderer

          @CanIgnoreReturnValue
          public ActionSchedule.Builder enableRenderer​(int index)

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

    - #### disableRenderer

          @CanIgnoreReturnValue
          public ActionSchedule.Builder disableRenderer​(int index)

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

    - #### clearVideoSurface

          @CanIgnoreReturnValue
          public ActionSchedule.Builder clearVideoSurface()

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

    - #### setVideoSurface

          @CanIgnoreReturnValue
          public ActionSchedule.Builder setVideoSurface()

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

    - #### setAudioAttributes

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

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

    - #### setMediaSources

          @CanIgnoreReturnValue
          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 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.
      Returns:
        The builder, for convenience.

    - #### setMediaSources

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          public ActionSchedule.Builder prepare()

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

    - #### clearMediaItems

          @CanIgnoreReturnValue
          public ActionSchedule.Builder clearMediaItems()

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

    - #### setRepeatMode

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          public ActionSchedule.Builder setShuffleModeEnabled​(boolean shuffleModeEnabled)

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

    - #### sendMessage

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

      Schedules sending a `PlayerMessage`.
      Parameters:
        `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 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.

    - #### sendMessage

          @CanIgnoreReturnValue
          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.

    - #### waitForTimelineChanged

          @CanIgnoreReturnValue
          public ActionSchedule.Builder waitForTimelineChanged()

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

    - #### waitForTimelineChanged

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          public ActionSchedule.Builder waitForPositionDiscontinuity()

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

    - #### waitForPlayWhenReady

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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

          @CanIgnoreReturnValue
          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.

    - #### waitForMessage

          @CanIgnoreReturnValue
          public ActionSchedule.Builder waitForMessage​(ActionSchedule.PlayerTarget 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 executeRunnable​(Runnable runnable)

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

    - #### throwPlaybackException

          @CanIgnoreReturnValue
          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.