AnalyticsListener, HostActivity.HostedTestpublic abstract class ExoHostedTest extends Object implements AnalyticsListener, HostActivity.HostedTest
HostActivity.HostedTest for ExoPlayer playback tests.AnalyticsListener.EventFlags, AnalyticsListener.Events, AnalyticsListener.EventTime| Modifier and Type | Field | Description |
|---|---|---|
static long |
EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS |
|
static long |
EXPECTED_PLAYING_TIME_UNSET |
|
static long |
MAX_PLAYING_TIME_DISCREPANCY_MS |
|
protected String |
tag |
EVENT_AUDIO_ATTRIBUTES_CHANGED, EVENT_AUDIO_DECODER_INITIALIZED, EVENT_AUDIO_DECODER_RELEASED, EVENT_AUDIO_DISABLED, EVENT_AUDIO_ENABLED, EVENT_AUDIO_INPUT_FORMAT_CHANGED, EVENT_AUDIO_POSITION_ADVANCING, EVENT_AUDIO_SESSION_ID, EVENT_AUDIO_SINK_ERROR, EVENT_AUDIO_UNDERRUN, EVENT_BANDWIDTH_ESTIMATE, EVENT_DOWNSTREAM_FORMAT_CHANGED, EVENT_DRM_KEYS_LOADED, EVENT_DRM_KEYS_REMOVED, EVENT_DRM_KEYS_RESTORED, EVENT_DRM_SESSION_ACQUIRED, EVENT_DRM_SESSION_MANAGER_ERROR, EVENT_DRM_SESSION_RELEASED, EVENT_DROPPED_VIDEO_FRAMES, EVENT_IS_LOADING_CHANGED, EVENT_IS_PLAYING_CHANGED, EVENT_LOAD_CANCELED, EVENT_LOAD_COMPLETED, EVENT_LOAD_ERROR, EVENT_LOAD_STARTED, EVENT_MEDIA_ITEM_TRANSITION, EVENT_METADATA, EVENT_PLAY_WHEN_READY_CHANGED, EVENT_PLAYBACK_PARAMETERS_CHANGED, EVENT_PLAYBACK_STATE_CHANGED, EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED, EVENT_PLAYER_ERROR, EVENT_PLAYER_RELEASED, EVENT_POSITION_DISCONTINUITY, EVENT_RENDERED_FIRST_FRAME, EVENT_REPEAT_MODE_CHANGED, EVENT_SHUFFLE_MODE_ENABLED_CHANGED, EVENT_SKIP_SILENCE_ENABLED_CHANGED, EVENT_STATIC_METADATA_CHANGED, EVENT_SURFACE_SIZE_CHANGED, EVENT_TIMELINE_CHANGED, EVENT_TRACKS_CHANGED, EVENT_UPSTREAM_DISCARDED, EVENT_VIDEO_DECODER_INITIALIZED, EVENT_VIDEO_DECODER_RELEASED, EVENT_VIDEO_DISABLED, EVENT_VIDEO_ENABLED, EVENT_VIDEO_FRAME_PROCESSING_OFFSET, EVENT_VIDEO_INPUT_FORMAT_CHANGED, EVENT_VIDEO_SIZE_CHANGED, EVENT_VOLUME_CHANGED| Constructor | Description |
|---|---|
ExoHostedTest(String tag,
boolean fullPlaybackNoSeeking) |
|
ExoHostedTest(String tag,
long expectedPlayingTimeMs,
boolean failOnPlayerError) |
| Modifier and Type | Method | Description |
|---|---|---|
protected void |
assertPassed(DecoderCounters audioCounters,
DecoderCounters videoCounters) |
|
boolean |
blockUntilStopped(long timeoutMs) |
Called on the main thread to block until the test has stopped or
HostActivity.HostedTest.forceStop() is
called. |
protected DrmSessionManager |
buildDrmSessionManager() |
|
protected SimpleExoPlayer |
buildExoPlayer(HostActivity host,
Surface surface,
MappingTrackSelector trackSelector) |
|
protected abstract MediaSource |
buildSource(HostActivity host,
DrmSessionManager drmSessionManager,
FrameLayout overlayFrameLayout) |
|
protected DefaultTrackSelector |
buildTrackSelector(HostActivity host) |
|
boolean |
forceStop() |
Called on the main thread to force stop the test (if it is not stopped already).
|
protected void |
logMetrics(DecoderCounters audioCounters,
DecoderCounters videoCounters) |
|
void |
onAudioDisabled(AnalyticsListener.EventTime eventTime,
DecoderCounters decoderCounters) |
Called when an audio renderer is disabled.
|
void |
onEvents(Player player,
AnalyticsListener.Events events) |
Called after one or more events occurred.
|
void |
onFinished() |
Called on the test thread after the test has finished and been stopped.
|
protected void |
onPlayerErrorInternal(ExoPlaybackException error) |
|
void |
onStart(HostActivity host,
Surface surface,
FrameLayout overlayFrameLayout) |
Called on the main thread when the test is started.
|
void |
onVideoDisabled(AnalyticsListener.EventTime eventTime,
DecoderCounters decoderCounters) |
Called when a video renderer is disabled.
|
void |
setSchedule(ActionSchedule schedule) |
Sets a schedule to be applied during the test.
|
onAudioAttributesChanged, onAudioDecoderInitialized, onAudioDecoderReleased, onAudioEnabled, onAudioInputFormatChanged, onAudioInputFormatChanged, onAudioPositionAdvancing, onAudioSessionIdChanged, onAudioSinkError, onAudioUnderrun, onBandwidthEstimate, onDecoderDisabled, onDecoderEnabled, onDecoderInitialized, onDecoderInputFormatChanged, onDownstreamFormatChanged, onDrmKeysLoaded, onDrmKeysRemoved, onDrmKeysRestored, onDrmSessionAcquired, onDrmSessionManagerError, onDrmSessionReleased, onDroppedVideoFrames, onIsLoadingChanged, onIsPlayingChanged, onLoadCanceled, onLoadCompleted, onLoadError, onLoadingChanged, onLoadStarted, onMediaItemTransition, onMetadata, onPlaybackParametersChanged, onPlaybackStateChanged, onPlaybackSuppressionReasonChanged, onPlayerError, onPlayerReleased, onPlayerStateChanged, onPlayWhenReadyChanged, onPositionDiscontinuity, onRenderedFirstFrame, onRepeatModeChanged, onSeekProcessed, onSeekStarted, onShuffleModeChanged, onSkipSilenceEnabledChanged, onStaticMetadataChanged, onSurfaceSizeChanged, onTimelineChanged, onTracksChanged, onUpstreamDiscarded, onVideoDecoderInitialized, onVideoDecoderReleased, onVideoEnabled, onVideoFrameProcessingOffset, onVideoInputFormatChanged, onVideoInputFormatChanged, onVideoSizeChanged, onVolumeChangedpublic static final long MAX_PLAYING_TIME_DISCREPANCY_MS
public static final long EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS
public static final long EXPECTED_PLAYING_TIME_UNSET
protected final String tag
public ExoHostedTest(String tag, boolean fullPlaybackNoSeeking)
tag - A tag to use for logging.fullPlaybackNoSeeking - Whether the test will play the target media in full without
seeking. If set to true, the test will assert that the total time spent playing the media
was within MAX_PLAYING_TIME_DISCREPANCY_MS of the media duration. If set to false,
the test will not assert an expected playing time.public ExoHostedTest(String tag, long expectedPlayingTimeMs, boolean failOnPlayerError)
tag - A tag to use for logging.expectedPlayingTimeMs - The expected playing time. If set to a non-negative value, the
test will assert that the total time spent playing the media was within
MAX_PLAYING_TIME_DISCREPANCY_MS of the specified value.
EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS should be passed to assert that the
expected playing time equals the duration of the media being played. Else
EXPECTED_PLAYING_TIME_UNSET should be passed to indicate that the test should not
assert an expected playing time.failOnPlayerError - Whether a player error should be considered a test failure.public final void setSchedule(ActionSchedule schedule)
schedule - The schedule.public final void onStart(HostActivity host, Surface surface, FrameLayout overlayFrameLayout)
HostActivity.HostedTestThe test will not be started until the HostActivity has been resumed and its
Surface has been created.
onStart in interface HostActivity.HostedTesthost - The HostActivity in which the test is being run.surface - The Surface.overlayFrameLayout - A FrameLayout that is on top of the surface.public final boolean blockUntilStopped(long timeoutMs)
HostActivity.HostedTestHostActivity.HostedTest.forceStop() is
called.blockUntilStopped in interface HostActivity.HostedTesttimeoutMs - The maximum time to block in milliseconds.public final boolean forceStop()
HostActivity.HostedTestforceStop in interface HostActivity.HostedTestpublic final void onFinished()
HostActivity.HostedTestImplementations may use this method to assert that test criteria were met.
onFinished in interface HostActivity.HostedTestpublic void onEvents(Player player, AnalyticsListener.Events events)
AnalyticsListenerState changes and events that happen within one Looper message queue iteration are
reported together and only after all individual callbacks were triggered.
Listeners should prefer this method over individual callbacks in the following cases:
AnalyticsListener.onPlaybackStateChanged(EventTime, int) and AnalyticsListener.onPlayWhenReadyChanged(EventTime, boolean, int)).
Player object to trigger further events (e.g. to call
Player.seekTo(long) after a AnalyticsListener.onMediaItemTransition(EventTime, MediaItem, int)).
Player
getter methods. For example using Player.getCurrentWindowIndex() with the
timeline provided in AnalyticsListener.onTimelineChanged(EventTime, int) is only safe from within
this method.
AnalyticsListener.onPlaybackStateChanged(EventTime, int) to Player.STATE_BUFFERING because of
AnalyticsListener.onMediaItemTransition(EventTime, MediaItem, int)).
onEvents in interface AnalyticsListenerplayer - The Player.events - The AnalyticsListener.Events that occurred in this iteration.public void onAudioDisabled(AnalyticsListener.EventTime eventTime, DecoderCounters decoderCounters)
AnalyticsListeneronAudioDisabled in interface AnalyticsListenereventTime - The event time.decoderCounters - DecoderCounters that were updated by the renderer.public void onVideoDisabled(AnalyticsListener.EventTime eventTime, DecoderCounters decoderCounters)
AnalyticsListeneronVideoDisabled in interface AnalyticsListenereventTime - The event time.decoderCounters - DecoderCounters that were updated by the renderer.protected DrmSessionManager buildDrmSessionManager()
protected DefaultTrackSelector buildTrackSelector(HostActivity host)
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface, MappingTrackSelector trackSelector)
protected abstract MediaSource buildSource(HostActivity host, DrmSessionManager drmSessionManager, FrameLayout overlayFrameLayout)
protected void onPlayerErrorInternal(ExoPlaybackException error)
protected void logMetrics(DecoderCounters audioCounters, DecoderCounters videoCounters)
protected void assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters)