Player.EventListener, ActionSchedule.Callbackpublic final class ExoPlayerTestRunner extends Object implements Player.EventListener, ActionSchedule.Callback
| Modifier and Type | Class | Description |
|---|---|---|
static class |
ExoPlayerTestRunner.Builder |
Builder to set-up a
ExoPlayerTestRunner. |
| Modifier and Type | Field | Description |
|---|---|---|
static Format |
AUDIO_FORMAT |
A generic audio
Format which can be used to set up a FakeMediaSource. |
static Format |
VIDEO_FORMAT |
A generic video
Format which can be used to set up a FakeMediaSource. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
assertMediaItemsTransitionedSame(MediaItem... mediaItems) |
Asserts that the media items reported by
Player.EventListener.onMediaItemTransition(MediaItem, int) are the same as the provided media
items. |
void |
assertMediaItemsTransitionReasonsEqual(Integer... reasons) |
Asserts that the media item transition reasons reported by
Player.EventListener.onMediaItemTransition(MediaItem, int) are the same as the provided
reasons. |
void |
assertNoPositionDiscontinuities() |
Asserts that
Player.EventListener.onPositionDiscontinuity(int) was not called. |
void |
assertPlaybackStatesEqual(Integer... states) |
Asserts that the playback states reported by
Player.EventListener.onPlaybackStateChanged(int) are equal to the provided playback states. |
void |
assertPlayedPeriodIndices(Integer... periodIndices) |
Asserts that the indices of played periods is equal to the provided list of periods.
|
void |
assertPositionDiscontinuityReasonsEqual(Integer... discontinuityReasons) |
Asserts that the discontinuity reasons reported by
Player.EventListener.onPositionDiscontinuity(int) are equal to the provided values. |
void |
assertTimelineChangeReasonsEqual(Integer... reasons) |
Asserts that the timeline change reasons reported by
Player.EventListener.onTimelineChanged(Timeline, int) are equal to the provided timeline
change reasons. |
void |
assertTimelinesSame(Timeline... timelines) |
Asserts that the timelines reported by
Player.EventListener.onTimelineChanged(Timeline,
int) are the same to the provided timelines. |
void |
assertTrackGroupsEqual(TrackGroupArray trackGroupArray) |
Asserts that the last track group array reported by
Player.EventListener.onTracksChanged(TrackGroupArray, TrackSelectionArray) is equal to the
provided track group array. |
ExoPlayerTestRunner |
blockUntilActionScheduleFinished(long timeoutMs) |
Blocks the current thread until the action schedule finished.
|
ExoPlayerTestRunner |
blockUntilEnded(long timeoutMs) |
Blocks the current thread until the test runner finishes.
|
void |
onActionScheduleFinished() |
Called when action schedule finished executing all its actions.
|
void |
onMediaItemTransition(MediaItem mediaItem,
int reason) |
Called when playback transitions to a media item or starts repeating a media item according
to the current
repeat mode. |
void |
onPlaybackStateChanged(int playbackState) |
Called when the value returned from
Player.getPlaybackState() changes. |
void |
onPlayerError(ExoPlaybackException error) |
Called when an error occurs.
|
void |
onPositionDiscontinuity(int reason) |
Called when a position discontinuity occurs without a change to the timeline.
|
void |
onTimelineChanged(Timeline timeline,
int reason) |
Called when the timeline has been refreshed.
|
void |
onTracksChanged(TrackGroupArray trackGroups,
TrackSelectionArray trackSelections) |
Called when the available or selected tracks change.
|
ExoPlayerTestRunner |
start() |
Starts the test runner on its own thread.
|
ExoPlayerTestRunner |
start(boolean doPrepare) |
Starts the test runner on its own thread.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonEvents, onExperimentalOffloadSchedulingEnabledChanged, onExperimentalSleepingForOffloadChanged, onIsLoadingChanged, onIsPlayingChanged, onLoadingChanged, onPlaybackParametersChanged, onPlaybackSuppressionReasonChanged, onPlayerStateChanged, onPlayWhenReadyChanged, onRepeatModeChanged, onSeekProcessed, onShuffleModeEnabledChanged, onStaticMetadataChanged, onTimelineChangedpublic static final Format VIDEO_FORMAT
Format which can be used to set up a FakeMediaSource.public static final Format AUDIO_FORMAT
Format which can be used to set up a FakeMediaSource.public ExoPlayerTestRunner start()
public ExoPlayerTestRunner start(boolean doPrepare)
doPrepare - Whether the player should be prepared.public ExoPlayerTestRunner blockUntilEnded(long timeoutMs) throws Exception
Player.STATE_ENDED or Player.STATE_IDLE for
the specified number of times. The test also finishes when an ExoPlaybackException is
thrown.timeoutMs - The maximum time to wait for the test runner to finish. If this time elapsed
the method will throw a TimeoutException.Exception - If any exception occurred during playback, release, or due to a timeout.public ExoPlayerTestRunner blockUntilActionScheduleFinished(long timeoutMs) throws TimeoutException, InterruptedException
blockUntilEnded(long).timeoutMs - The maximum time to wait for the action schedule to finish.TimeoutException - If the action schedule did not finish within the specified timeout.InterruptedException - If the test thread gets interrupted while waiting.public void assertTimelinesSame(Timeline... timelines)
Player.EventListener.onTimelineChanged(Timeline,
int) are the same to the provided timelines. This assert differs from testing equality by not
comparing period ids which may be different due to id mapping of child source period ids.timelines - A list of expected Timelines.public void assertTimelineChangeReasonsEqual(Integer... reasons)
Player.EventListener.onTimelineChanged(Timeline, int) are equal to the provided timeline
change reasons.public void assertMediaItemsTransitionedSame(MediaItem... mediaItems)
Player.EventListener.onMediaItemTransition(MediaItem, int) are the same as the provided media
items.mediaItems - A list of expected media items.public void assertMediaItemsTransitionReasonsEqual(Integer... reasons)
Player.EventListener.onMediaItemTransition(MediaItem, int) are the same as the provided
reasons.reasons - A list of expected transition reasons.public void assertPlaybackStatesEqual(Integer... states)
Player.EventListener.onPlaybackStateChanged(int) are equal to the provided playback states.public void assertTrackGroupsEqual(TrackGroupArray trackGroupArray)
Player.EventListener.onTracksChanged(TrackGroupArray, TrackSelectionArray) is equal to the
provided track group array.trackGroupArray - The expected TrackGroupArray.public void assertNoPositionDiscontinuities()
Player.EventListener.onPositionDiscontinuity(int) was not called.public void assertPositionDiscontinuityReasonsEqual(Integer... discontinuityReasons)
Player.EventListener.onPositionDiscontinuity(int) are equal to the provided values.discontinuityReasons - The expected discontinuity reasons.public void assertPlayedPeriodIndices(Integer... periodIndices)
periodIndices - A list of expected period indices.public void onTimelineChanged(Timeline timeline, @TimelineChangeReason int reason)
Player.EventListenerNote that if the timeline has changed then a position discontinuity may also have
occurred. For example, the current period index may have changed as a result of periods being
added or removed from the timeline. This will not be reported via a separate call to
Player.EventListener.onPositionDiscontinuity(int).
Player.EventListener.onEvents(Player, Events) will also be called to report this event along with
other events that happen in the same Looper message queue iteration.
onTimelineChanged in interface Player.EventListenertimeline - The latest timeline. Never null, but may be empty.reason - The Player.TimelineChangeReason responsible for this timeline change.public void onMediaItemTransition(@Nullable
MediaItem mediaItem,
@MediaItemTransitionReason
int reason)
Player.EventListenerrepeat mode.
Note that this callback is also called when the playlist becomes non-empty or empty as a consequence of a playlist change.
Player.EventListener.onEvents(Player, Events) will also be called to report this event along with
other events that happen in the same Looper message queue iteration.
onMediaItemTransition in interface Player.EventListenermediaItem - The MediaItem. May be null if the playlist becomes empty.reason - The reason for the transition.public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections)
Player.EventListenerPlayer.EventListener.onEvents(Player, Events) will also be called to report this event along with
other events that happen in the same Looper message queue iteration.
onTracksChanged in interface Player.EventListenertrackGroups - The available tracks. Never null, but may be of length zero.trackSelections - The track selections for each renderer. Never null and always of
length Player.getRendererCount(), but may contain null elements.public void onPlaybackStateChanged(@State int playbackState)
Player.EventListenerPlayer.getPlaybackState() changes.
Player.EventListener.onEvents(Player, Events) will also be called to report this event along with
other events that happen in the same Looper message queue iteration.
onPlaybackStateChanged in interface Player.EventListenerplaybackState - The new playback state.public void onPlayerError(ExoPlaybackException error)
Player.EventListenerPlayer.STATE_IDLE
immediately after this method is called. The player instance can still be used, and Player.release() must still be called on the player should it no longer be required.
Player.EventListener.onEvents(Player, Events) will also be called to report this event along with
other events that happen in the same Looper message queue iteration.
onPlayerError in interface Player.EventListenererror - The error.public void onPositionDiscontinuity(@DiscontinuityReason int reason)
Player.EventListenerWhen a position discontinuity occurs as a result of a change to the timeline this method
is not called. Player.EventListener.onTimelineChanged(Timeline, int) is called in this case.
Player.EventListener.onEvents(Player, Events) will also be called to report this event along with
other events that happen in the same Looper message queue iteration.
onPositionDiscontinuity in interface Player.EventListenerreason - The Player.DiscontinuityReason responsible for the discontinuity.public void onActionScheduleFinished()
ActionSchedule.CallbackonActionScheduleFinished in interface ActionSchedule.Callback