# Action

Artifact: [androidx.media3:media3-test-utils](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/test/utils/Action.java+class:androidx.media3.test.utils.Action)

*** ** * ** ***


```
@UnstableApi
public abstract class Action
```

<br />

Known direct subclasses [Action.AddMediaItems](https://developer.android.com/reference/androidx/media3/test/utils/Action.AddMediaItems), [Action.ClearMediaItems](https://developer.android.com/reference/androidx/media3/test/utils/Action.ClearMediaItems), [Action.ClearVideoSurface](https://developer.android.com/reference/androidx/media3/test/utils/Action.ClearVideoSurface), [Action.ExecuteRunnable](https://developer.android.com/reference/androidx/media3/test/utils/Action.ExecuteRunnable), [Action.MoveMediaItem](https://developer.android.com/reference/androidx/media3/test/utils/Action.MoveMediaItem), [Action.PlayUntilPosition](https://developer.android.com/reference/androidx/media3/test/utils/Action.PlayUntilPosition), [Action.Prepare](https://developer.android.com/reference/androidx/media3/test/utils/Action.Prepare), [Action.RemoveMediaItem](https://developer.android.com/reference/androidx/media3/test/utils/Action.RemoveMediaItem), [Action.RemoveMediaItems](https://developer.android.com/reference/androidx/media3/test/utils/Action.RemoveMediaItems), [Action.Seek](https://developer.android.com/reference/androidx/media3/test/utils/Action.Seek), [Action.SendMessages](https://developer.android.com/reference/androidx/media3/test/utils/Action.SendMessages), [Action.SetAudioAttributes](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetAudioAttributes), [Action.SetMediaItemsResetPosition](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetMediaItemsResetPosition), [Action.SetMediaItems](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetMediaItems), [Action.SetPlayWhenReady](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetPlayWhenReady), [Action.SetPlaybackParameters](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetPlaybackParameters), [Action.SetRendererDisabled](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetRendererDisabled), [Action.SetRepeatMode](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetRepeatMode), [Action.SetShuffleModeEnabled](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetShuffleModeEnabled), [Action.SetShuffleOrder](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetShuffleOrder), [Action.SetVideoSurface](https://developer.android.com/reference/androidx/media3/test/utils/Action.SetVideoSurface), [Action.Stop](https://developer.android.com/reference/androidx/media3/test/utils/Action.Stop), [Action.ThrowPlaybackException](https://developer.android.com/reference/androidx/media3/test/utils/Action.ThrowPlaybackException), [Action.WaitForIsLoading](https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForIsLoading), [Action.WaitForMessage](https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForMessage), [Action.WaitForPendingPlayerCommands](https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPendingPlayerCommands), [Action.WaitForPlayWhenReady](https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPlayWhenReady), [Action.WaitForPlaybackState](https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPlaybackState), [Action.WaitForPositionDiscontinuity](https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPositionDiscontinuity), [Action.WaitForTimelineChanged](https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForTimelineChanged)

|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.AddMediaItems` | Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#addMediaSources(java.util.List<androidx.media3.exoplayer.source.MediaSource>)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.ClearMediaItems` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#clearMediaItems()`}. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.ClearVideoSurface` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#clearVideoSurface()`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.ExecuteRunnable` | Calls `Runnable.run()`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.MoveMediaItem` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#moveMediaItem(int,int)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.PlayUntilPosition` | Schedules a play action to be executed, waits until the player reaches the specified position, and pauses the player again. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.Prepare` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#prepare()`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.RemoveMediaItem` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#removeMediaItem(int)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.RemoveMediaItems` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#removeMediaItems(int,int)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.Seek` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#seekTo(long)` or `https://developer.android.com/reference/androidx/media3/common/Player#seekTo(int,long)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SendMessages` | Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#createMessage(androidx.media3.exoplayer.PlayerMessage.Target)` and `https://developer.android.com/reference/androidx/media3/exoplayer/PlayerMessage#send()`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetAudioAttributes` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#setAudioAttributes(androidx.media3.common.AudioAttributes,boolean)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetMediaItemsResetPosition` | Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#setMediaSources(java.util.List<androidx.media3.exoplayer.source.MediaSource>,boolean)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetMediaItems` | Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#setMediaSources(java.util.List<androidx.media3.exoplayer.source.MediaSource>,int,long)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetPlayWhenReady` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#setPlayWhenReady(boolean)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetPlaybackParameters` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#setPlaybackParameters(androidx.media3.common.PlaybackParameters)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetRendererDisabled` | Updates the `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters` of a `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/DefaultTrackSelector` to specify whether the renderer at a given index should be disabled. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetRepeatMode` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#setRepeatMode(int)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetShuffleModeEnabled` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#setShuffleModeEnabled(boolean)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetShuffleOrder` | Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#setShuffleOrder(androidx.media3.exoplayer.source.ShuffleOrder)` . |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.SetVideoSurface` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#setVideoSurface(android.view.Surface)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.Stop` | Calls `https://developer.android.com/reference/androidx/media3/common/Player#stop()`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.ThrowPlaybackException` | Throws a playback exception on the playback thread. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForIsLoading` | Waits for a specified loading state, returning either immediately or after a call to `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsLoadingChanged(boolean)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForMessage` | Waits for a player message to arrive. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPendingPlayerCommands` | Waits until the player acknowledged all pending player commands. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPlayWhenReady` | Waits for a specified playWhenReady value, returning either immediately or after a call to `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayWhenReadyChanged(boolean,int)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPlaybackState` | Waits for a specified playback state, returning either immediately or after a call to `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPositionDiscontinuity` | Waits for `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)`. |
| `https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForTimelineChanged` | Waits for `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onTimelineChanged(androidx.media3.common.Timeline,int)`. |

*** ** * ** ***

Base class for actions to perform during playback tests.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.AddMediaItems extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#addMediaSources(java.util.List<androidx.media3.exoplayer.source.MediaSource>)`. |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/Action.ClearMediaItems extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#clearMediaItems()`}. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.ClearVideoSurface extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#clearVideoSurface()`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.ExecuteRunnable extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `Runnable.run()`. |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/Action.MoveMediaItem extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#moveMediaItem(int,int)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.PlayUntilPosition extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Schedules a play action to be executed, waits until the player reaches the specified position, and pauses the player again. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.Prepare extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#prepare()`. |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/Action.RemoveMediaItem extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#removeMediaItem(int)`. |
| `public class https://developer.android.com/reference/androidx/media3/test/utils/Action.RemoveMediaItems extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#removeMediaItems(int,int)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.Seek extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#seekTo(long)` or `https://developer.android.com/reference/androidx/media3/common/Player#seekTo(int,long)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SendMessages extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#createMessage(androidx.media3.exoplayer.PlayerMessage.Target)` and `https://developer.android.com/reference/androidx/media3/exoplayer/PlayerMessage#send()`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetAudioAttributes extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#setAudioAttributes(androidx.media3.common.AudioAttributes,boolean)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetMediaItems extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#setMediaSources(java.util.List<androidx.media3.exoplayer.source.MediaSource>,int,long)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetMediaItemsResetPosition extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#setMediaSources(java.util.List<androidx.media3.exoplayer.source.MediaSource>,boolean)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetPlayWhenReady extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#setPlayWhenReady(boolean)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetPlaybackParameters extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#setPlaybackParameters(androidx.media3.common.PlaybackParameters)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetRendererDisabled extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Updates the `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.Parameters` of a `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/DefaultTrackSelector` to specify whether the renderer at a given index should be disabled. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetRepeatMode extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#setRepeatMode(int)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetShuffleModeEnabled extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#setShuffleModeEnabled(boolean)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetShuffleOrder extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer#setShuffleOrder(androidx.media3.exoplayer.source.ShuffleOrder)` . |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.SetVideoSurface extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#setVideoSurface(android.view.Surface)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.Stop extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Calls `https://developer.android.com/reference/androidx/media3/common/Player#stop()`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.ThrowPlaybackException extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Throws a playback exception on the playback thread. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForIsLoading extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Waits for a specified loading state, returning either immediately or after a call to `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onIsLoadingChanged(boolean)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForMessage extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Waits for a player message to arrive. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPendingPlayerCommands extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Waits until the player acknowledged all pending player commands. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPlayWhenReady extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Waits for a specified playWhenReady value, returning either immediately or after a call to `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlayWhenReadyChanged(boolean,int)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPlaybackState extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Waits for a specified playback state, returning either immediately or after a call to `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPlaybackStateChanged(int)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForPositionDiscontinuity extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Waits for `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onPositionDiscontinuity(androidx.media3.common.Player.PositionInfo,androidx.media3.common.Player.PositionInfo,int)`. |
| `public final class https://developer.android.com/reference/androidx/media3/test/utils/Action.WaitForTimelineChanged extends https://developer.android.com/reference/androidx/media3/test/utils/Action` Waits for `https://developer.android.com/reference/androidx/media3/common/Player.Listener#onTimelineChanged(androidx.media3.common.Timeline,int)`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/Action#Action(java.lang.String,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html description)` |

| ### Protected methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/test/utils/Action#doActionImpl(androidx.media3.exoplayer.ExoPlayer,androidx.media3.exoplayer.trackselection.DefaultTrackSelector,android.view.Surface)( https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player, https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/DefaultTrackSelector trackSelector, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/Surface.html surface )` Called by `https://developer.android.com/reference/androidx/media3/test/utils/Action#doActionAndScheduleNextImpl(androidx.media3.exoplayer.ExoPlayer,androidx.media3.exoplayer.trackselection.DefaultTrackSelector,android.view.Surface,androidx.media3.common.util.HandlerWrapper,androidx.media3.test.utils.ActionSchedule.ActionNode)` to perform the action. |

## Public constructors

### Action

```
public Action(@Size(max = 23) String tag, @Nullable String description)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | A tag to use for logging. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html description` | A description to be logged when the action is executed, or null if no logging is required. |

## Protected methods

### doActionImpl

```
protected abstract void doActionImpl(
    ExoPlayer player,
    DefaultTrackSelector trackSelector,
    @Nullable Surface surface
)
```

Called by `https://developer.android.com/reference/androidx/media3/test/utils/Action#doActionAndScheduleNextImpl(androidx.media3.exoplayer.ExoPlayer,androidx.media3.exoplayer.trackselection.DefaultTrackSelector,android.view.Surface,androidx.media3.common.util.HandlerWrapper,androidx.media3.test.utils.ActionSchedule.ActionNode)` to perform the action.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/ExoPlayer player` | The player to which the action should be applied. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/trackselection/DefaultTrackSelector trackSelector` | The track selector to which the action should be applied. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/android/view/Surface.html surface` | The surface to use when applying actions, or `null` if no surface is needed. |