Class ExoPlayerTestRunner.Builder
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.ExoPlayerTestRunner.Builder
-
- Enclosing class:
- ExoPlayerTestRunner
public static final class ExoPlayerTestRunner.Builder extends Object
Builder to set-up anExoPlayerTestRunner
. Default fake implementations will be used for unset test properties.
-
-
Method Summary
-
-
-
Constructor Detail
-
Builder
public Builder(Context context)
-
-
Method Detail
-
setTimeline
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setTimeline(Timeline timeline)
Sets aTimeline
to be used by aFakeMediaSource
in the test runner. The default value is a seekable, non-dynamicFakeTimeline
with a duration ofFakeTimeline.TimelineWindowDefinition.DEFAULT_WINDOW_DURATION_US
. Setting the timeline is not allowed after a call tosetMediaSources(MediaSource...)
orskipSettingMediaSources()
.- Parameters:
timeline
- ATimeline
to be used by aFakeMediaSource
in the test runner.- Returns:
- This builder.
-
setManifest
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setManifest(Object manifest)
Sets a manifest to be used by aFakeMediaSource
in the test runner. The default value is null. Setting the manifest is not allowed after a call tosetMediaSources(MediaSource...)
orskipSettingMediaSources()
.- Parameters:
manifest
- A manifest to be used by aFakeMediaSource
in the test runner.- Returns:
- This builder.
-
initialSeek
@CanIgnoreReturnValue 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.
-
setMediaSources
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setMediaSources(MediaSource... mediaSources)
Sets theMediaSource
s to be used by the test runner. The default value is aFakeMediaSource
with the timeline and manifest provided bysetTimeline(Timeline)
andsetManifest(Object)
. Setting media sources is not allowed after calls toskipSettingMediaSources()
,setTimeline(Timeline)
and/orsetManifest(Object)
.- Parameters:
mediaSources
- TheMediaSource
s to be used by the test runner.- Returns:
- This builder.
-
setSupportedFormats
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setSupportedFormats(Format... supportedFormats)
Sets a list ofFormat
s to be used by aFakeMediaSource
to create media periods. The default value is a singleExoPlayerTestRunner.VIDEO_FORMAT
. Note that this parameter doesn't have any influence if a media source withsetMediaSources(MediaSource...)
is set.- Parameters:
supportedFormats
- A list of supportedFormat
s.- Returns:
- This builder.
-
skipSettingMediaSources
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder skipSettingMediaSources()
Skips callingExoPlayer.setMediaSources(List)
before preparing. Calling this method is not allowed after calls tosetMediaSources(MediaSource...)
,setTimeline(Timeline)
and/orsetManifest(Object)
.- Returns:
- This builder.
-
setUseLazyPreparation
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setUseLazyPreparation(boolean useLazyPreparation)
- Returns:
- This builder.
- See Also:
TestExoPlayerBuilder.setUseLazyPreparation(boolean)
-
setPauseAtEndOfMediaItems
@CanIgnoreReturnValue 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.
-
setTrackSelector
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setTrackSelector(DefaultTrackSelector trackSelector)
- Returns:
- This builder.
- See Also:
TestExoPlayerBuilder.setTrackSelector(DefaultTrackSelector)
-
setLoadControl
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setLoadControl(LoadControl loadControl)
- Returns:
- This builder.
- See Also:
TestExoPlayerBuilder.setLoadControl(LoadControl)
-
setBandwidthMeter
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setBandwidthMeter(BandwidthMeter bandwidthMeter)
- Returns:
- This builder.
- See Also:
TestExoPlayerBuilder.setBandwidthMeter(BandwidthMeter)
-
setRenderers
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setRenderers(Renderer... renderers)
- Returns:
- This builder.
- See Also:
TestExoPlayerBuilder.setRenderers(Renderer...)
-
setRenderersFactory
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setRenderersFactory(RenderersFactory renderersFactory)
- Returns:
- This builder.
- See Also:
TestExoPlayerBuilder.setRenderersFactory(RenderersFactory)
-
setClock
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setClock(Clock clock)
- Returns:
- This builder.
- See Also:
TestExoPlayerBuilder.setClock(Clock)
-
setActionSchedule
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setActionSchedule(ActionSchedule actionSchedule)
Sets anActionSchedule
to be run by the test runner. The first action will be executed immediately beforePlayer.prepare()
.- Parameters:
actionSchedule
- AnActionSchedule
to be used by the test runner.- Returns:
- This builder.
-
setVideoSurface
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setVideoSurface(Surface surface)
Sets the videoSurface
. The default value isnull
.- Parameters:
surface
- TheSurface
to be used by the player.- Returns:
- This builder.
-
setPlayerListener
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setPlayerListener(Player.Listener playerListener)
Sets anPlayer.Listener
to be registered to listen to player events.- Parameters:
playerListener
- APlayer.Listener
to be registered by the test runner to listen to player events.- Returns:
- This builder.
-
setAnalyticsListener
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setAnalyticsListener(AnalyticsListener analyticsListener)
Sets anAnalyticsListener
to be registered.- Parameters:
analyticsListener
- AnAnalyticsListener
to be registered.- Returns:
- This builder.
-
setExpectedPlayerEndedCount
@CanIgnoreReturnValue public ExoPlayerTestRunner.Builder setExpectedPlayerEndedCount(int expectedPlayerEndedCount)
Sets the number of times the test runner is expected to reach thePlayer.STATE_ENDED
orPlayer.STATE_IDLE
. The default is 1. This affects how longExoPlayerTestRunner.blockUntilEnded(long)
waits.- Parameters:
expectedPlayerEndedCount
- The number of times the player is expected to reach the ended or idle state.- Returns:
- This builder.
-
build
public ExoPlayerTestRunner build()
Builds anExoPlayerTestRunner
using the provided values or their defaults.- Returns:
- The built
ExoPlayerTestRunner
.
-
-