public final class

ExoPlayerTestRunner.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.test.utils.ExoPlayerTestRunner.Builder

Overview

Builder to set-up an ExoPlayerTestRunner. Default fake implementations will be used for unset test properties.

Summary

Constructors
publicBuilder(Context context)

Methods
public ExoPlayerTestRunnerbuild()

Builds an ExoPlayerTestRunner using the provided values or their defaults.

public ExoPlayerTestRunner.BuilderinitialSeek(int mediaItemIndex, long positionMs)

Seeks before setting the media sources and preparing the player.

public ExoPlayerTestRunner.BuildersetActionSchedule(ActionSchedule actionSchedule)

Sets an ActionSchedule to be run by the test runner.

public ExoPlayerTestRunner.BuildersetAnalyticsListener(AnalyticsListener analyticsListener)

Sets an AnalyticsListener to be registered.

public ExoPlayerTestRunner.BuildersetBandwidthMeter(BandwidthMeter bandwidthMeter)

public ExoPlayerTestRunner.BuildersetClock(Clock clock)

public ExoPlayerTestRunner.BuildersetExpectedPlayerEndedCount(int expectedPlayerEndedCount)

Sets the number of times the test runner is expected to reach the Player.STATE_ENDED or Player.STATE_IDLE.

public ExoPlayerTestRunner.BuildersetLoadControl(LoadControl loadControl)

public ExoPlayerTestRunner.BuildersetManifest(java.lang.Object manifest)

Sets a manifest to be used by a FakeMediaSource in the test runner.

public ExoPlayerTestRunner.BuildersetMediaSources(MediaSource mediaSources[])

Sets the MediaSources to be used by the test runner.

public ExoPlayerTestRunner.BuildersetPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)

Sets whether to enable pausing at the end of media items.

public ExoPlayerTestRunner.BuildersetPlayerListener(Player.Listener playerListener)

Sets an to be registered to listen to player events.

public ExoPlayerTestRunner.BuildersetPreloadConfiguration(ExoPlayer.PreloadConfiguration preloadConfiguration)

public ExoPlayerTestRunner.BuildersetRenderers(Renderer renderers[])

public ExoPlayerTestRunner.BuildersetRenderersFactory(RenderersFactory renderersFactory)

public ExoPlayerTestRunner.BuildersetSupportedFormats(Format supportedFormats[])

Sets a list of Formats to be used by a FakeMediaSource to create media periods.

public ExoPlayerTestRunner.BuildersetTimeline(Timeline timeline)

Sets a Timeline to be used by a FakeMediaSource in the test runner.

public ExoPlayerTestRunner.BuildersetTrackSelector(DefaultTrackSelector trackSelector)

public ExoPlayerTestRunner.BuildersetUseLazyPreparation(boolean useLazyPreparation)

public ExoPlayerTestRunner.BuildersetVideoSurface(Surface surface)

Sets the video .

public ExoPlayerTestRunner.BuilderskipSettingMediaSources()

Skips calling ExoPlayer.setMediaSources(List) before preparing.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder(Context context)

Methods

public ExoPlayerTestRunner.Builder setTimeline(Timeline timeline)

Sets a Timeline to be used by a FakeMediaSource in the test runner. The default value is a seekable, non-dynamic FakeTimeline with a duration of FakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US. Setting the timeline is not allowed after a call to ExoPlayerTestRunner.Builder.setMediaSources(MediaSource...) or ExoPlayerTestRunner.Builder.skipSettingMediaSources().

Parameters:

timeline: A Timeline to be used by a FakeMediaSource in the test runner.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setManifest(java.lang.Object manifest)

Sets a manifest to be used by a FakeMediaSource in the test runner. The default value is null. Setting the manifest is not allowed after a call to ExoPlayerTestRunner.Builder.setMediaSources(MediaSource...) or ExoPlayerTestRunner.Builder.skipSettingMediaSources().

Parameters:

manifest: A manifest to be used by a FakeMediaSource in the test runner.

Returns:

This builder.

public ExoPlayerTestRunner.Builder initialSeek(int mediaItemIndex, long positionMs)

Seeks before setting the media sources and preparing the player.

Parameters:

mediaItemIndex: The media item index to seek to.
positionMs: The position in milliseconds to seek to.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setMediaSources(MediaSource mediaSources[])

Sets the MediaSources to be used by the test runner. The default value is a FakeMediaSource with the timeline and manifest provided by ExoPlayerTestRunner.Builder.setTimeline(Timeline) and ExoPlayerTestRunner.Builder.setManifest(Object). Setting media sources is not allowed after calls to ExoPlayerTestRunner.Builder.skipSettingMediaSources(), ExoPlayerTestRunner.Builder.setTimeline(Timeline) and/or ExoPlayerTestRunner.Builder.setManifest(Object).

Parameters:

mediaSources: The MediaSources to be used by the test runner.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setSupportedFormats(Format supportedFormats[])

Sets a list of Formats to be used by a FakeMediaSource to create media periods. The default value is a single ExoPlayerTestRunner.VIDEO_FORMAT. Note that this parameter doesn't have any influence if a media source with ExoPlayerTestRunner.Builder.setMediaSources(MediaSource...) is set.

Parameters:

supportedFormats: A list of supported Formats.

Returns:

This builder.

public ExoPlayerTestRunner.Builder skipSettingMediaSources()

Skips calling ExoPlayer.setMediaSources(List) before preparing. Calling this method is not allowed after calls to ExoPlayerTestRunner.Builder.setMediaSources(MediaSource...), ExoPlayerTestRunner.Builder.setTimeline(Timeline) and/or ExoPlayerTestRunner.Builder.setManifest(Object).

Returns:

This builder.

public ExoPlayerTestRunner.Builder setUseLazyPreparation(boolean useLazyPreparation)

Returns:

This builder.

See also: TestExoPlayerBuilder.setUseLazyPreparation(boolean)

public ExoPlayerTestRunner.Builder setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems)

Sets whether to enable pausing at the end of media items.

Parameters:

pauseAtEndOfMediaItems: Whether to pause at the end of media items.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setTrackSelector(DefaultTrackSelector trackSelector)

Returns:

This builder.

See also: TestExoPlayerBuilder.setTrackSelector(DefaultTrackSelector)

public ExoPlayerTestRunner.Builder setLoadControl(LoadControl loadControl)

Returns:

This builder.

See also: TestExoPlayerBuilder.setLoadControl(LoadControl)

public ExoPlayerTestRunner.Builder setBandwidthMeter(BandwidthMeter bandwidthMeter)

Returns:

This builder.

See also: TestExoPlayerBuilder.setBandwidthMeter(BandwidthMeter)

public ExoPlayerTestRunner.Builder setRenderers(Renderer renderers[])

Returns:

This builder.

See also: TestExoPlayerBuilder.setRenderers(Renderer...)

public ExoPlayerTestRunner.Builder setRenderersFactory(RenderersFactory renderersFactory)

Returns:

This builder.

See also: TestExoPlayerBuilder.setRenderersFactory(RenderersFactory)

public ExoPlayerTestRunner.Builder setClock(Clock clock)

Returns:

This builder.

See also: TestExoPlayerBuilder.setClock(Clock)

public ExoPlayerTestRunner.Builder setPreloadConfiguration(ExoPlayer.PreloadConfiguration preloadConfiguration)

Returns:

This builder.

See also: ExoPlayer.setPreloadConfiguration(ExoPlayer.PreloadConfiguration)

public ExoPlayerTestRunner.Builder setActionSchedule(ActionSchedule actionSchedule)

Sets an ActionSchedule to be run by the test runner. The first action will be executed immediately before Player.prepare().

Parameters:

actionSchedule: An ActionSchedule to be used by the test runner.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setVideoSurface(Surface surface)

Sets the video . The default value is null.

Parameters:

surface: The to be used by the player.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setPlayerListener(Player.Listener playerListener)

Sets an to be registered to listen to player events.

Parameters:

playerListener: A to be registered by the test runner to listen to player events.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setAnalyticsListener(AnalyticsListener analyticsListener)

Sets an AnalyticsListener to be registered.

Parameters:

analyticsListener: An AnalyticsListener to be registered.

Returns:

This builder.

public ExoPlayerTestRunner.Builder setExpectedPlayerEndedCount(int expectedPlayerEndedCount)

Sets the number of times the test runner is expected to reach the Player.STATE_ENDED or Player.STATE_IDLE. The default is 1. This affects how long ExoPlayerTestRunner.blockUntilEnded(long) waits.

Parameters:

expectedPlayerEndedCount: The number of times the player is expected to reach the ended or idle state.

Returns:

This builder.

public ExoPlayerTestRunner build()

Builds an ExoPlayerTestRunner using the provided values or their defaults.

Returns:

The built ExoPlayerTestRunner.