Class TestExoPlayerBuilder
- java.lang.Object
-
- com.google.android.exoplayer2.testutil.TestExoPlayerBuilder
-
public class TestExoPlayerBuilder extends Object
A builder ofSimpleExoPlayer
instances for testing.
-
-
Constructor Summary
Constructors Constructor Description TestExoPlayerBuilder(Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleExoPlayer
build()
Builds anSimpleExoPlayer
using the provided values or their defaults.BandwidthMeter
getBandwidthMeter()
Returns the bandwidth meter used by the player.Clock
getClock()
Returns the clock used by the player.LoadControl
getLoadControl()
Returns theLoadControl
that will be used by the player.Looper
getLooper()
MediaSourceFactory
getMediaSourceFactory()
Returns theMediaSourceFactory
that will be used by the player, or null if noMediaSourceFactory
has been set yet and no default is available.Renderer[]
getRenderers()
Returns theRenderers
that have been set withsetRenderers(com.google.android.exoplayer2.Renderer...)
or null if noRenderers
have been explicitly set.RenderersFactory
getRenderersFactory()
Returns theRenderersFactory
that has been set withsetRenderersFactory(com.google.android.exoplayer2.RenderersFactory)
or null if no factory has been explicitly set.long
getSeekBackIncrementMs()
Returns the seek back increment used by the player.long
getSeekForwardIncrementMs()
Returns the seek forward increment used by the player.DefaultTrackSelector
getTrackSelector()
Returns the track selector used by the player.boolean
getUseLazyPreparation()
Returns whether the player will use lazy preparation.TestExoPlayerBuilder
setBandwidthMeter(BandwidthMeter bandwidthMeter)
Sets theBandwidthMeter
.TestExoPlayerBuilder
setClock(Clock clock)
Sets theClock
to be used by the player.TestExoPlayerBuilder
setLoadControl(LoadControl loadControl)
Sets aLoadControl
to be used by the player.TestExoPlayerBuilder
setLooper(Looper looper)
Sets theLooper
to be used by the player.TestExoPlayerBuilder
setMediaSourceFactory(MediaSourceFactory mediaSourceFactory)
Sets theMediaSourceFactory
to be used by the player.TestExoPlayerBuilder
setRenderers(Renderer... renderers)
Sets theRenderer
s.TestExoPlayerBuilder
setRenderersFactory(RenderersFactory renderersFactory)
Sets theRenderersFactory
.TestExoPlayerBuilder
setSeekBackIncrementMs(long seekBackIncrementMs)
Sets the seek back increment to be used by the player.TestExoPlayerBuilder
setSeekForwardIncrementMs(long seekForwardIncrementMs)
Sets the seek forward increment to be used by the player.TestExoPlayerBuilder
setTrackSelector(DefaultTrackSelector trackSelector)
Sets aDefaultTrackSelector
.TestExoPlayerBuilder
setUseLazyPreparation(boolean useLazyPreparation)
Sets whether to use lazy preparation.
-
-
-
Constructor Detail
-
TestExoPlayerBuilder
public TestExoPlayerBuilder(Context context)
-
-
Method Detail
-
setUseLazyPreparation
public TestExoPlayerBuilder setUseLazyPreparation(boolean useLazyPreparation)
Sets whether to use lazy preparation.- Parameters:
useLazyPreparation
- Whether to use lazy preparation.- Returns:
- This builder.
-
getUseLazyPreparation
public boolean getUseLazyPreparation()
Returns whether the player will use lazy preparation.
-
setTrackSelector
public TestExoPlayerBuilder setTrackSelector(DefaultTrackSelector trackSelector)
Sets aDefaultTrackSelector
. The default value is aDefaultTrackSelector
in its initial configuration.- Parameters:
trackSelector
- TheDefaultTrackSelector
to be used by the player.- Returns:
- This builder.
-
getTrackSelector
public DefaultTrackSelector getTrackSelector()
Returns the track selector used by the player.
-
setLoadControl
public TestExoPlayerBuilder setLoadControl(LoadControl loadControl)
Sets aLoadControl
to be used by the player. The default value is aDefaultLoadControl
.- Parameters:
loadControl
- TheLoadControl
to be used by the player.- Returns:
- This builder.
-
getLoadControl
public LoadControl getLoadControl()
Returns theLoadControl
that will be used by the player.
-
setBandwidthMeter
public TestExoPlayerBuilder setBandwidthMeter(BandwidthMeter bandwidthMeter)
Sets theBandwidthMeter
. The default value is aDefaultBandwidthMeter
in its default configuration.- Parameters:
bandwidthMeter
- TheBandwidthMeter
to be used by the player.- Returns:
- This builder.
-
getBandwidthMeter
public BandwidthMeter getBandwidthMeter()
Returns the bandwidth meter used by the player.
-
setRenderers
public TestExoPlayerBuilder setRenderers(Renderer... renderers)
Sets theRenderer
s. If not set, the player will use aFakeVideoRenderer
and aFakeAudioRenderer
. Setting the renderers is not allowed after a call tosetRenderersFactory(RenderersFactory)
.- Parameters:
renderers
- A list ofRenderer
s to be used by the player.- Returns:
- This builder.
-
getRenderers
@Nullable public Renderer[] getRenderers()
Returns theRenderers
that have been set withsetRenderers(com.google.android.exoplayer2.Renderer...)
or null if noRenderers
have been explicitly set. Note that these renderers may not be the ones used by the built player, for example if aRenderer factory
has been set.
-
setRenderersFactory
public TestExoPlayerBuilder setRenderersFactory(RenderersFactory renderersFactory)
Sets theRenderersFactory
. The default factory creates all renderers set bysetRenderers(Renderer...)
. Setting the renderer factory is not allowed after a call tosetRenderers(Renderer...)
.- Parameters:
renderersFactory
- ARenderersFactory
to be used by the player.- Returns:
- This builder.
-
getRenderersFactory
@Nullable public RenderersFactory getRenderersFactory()
Returns theRenderersFactory
that has been set withsetRenderersFactory(com.google.android.exoplayer2.RenderersFactory)
or null if no factory has been explicitly set.
-
setClock
public TestExoPlayerBuilder setClock(Clock clock)
- Parameters:
clock
- AClock
to be used by the player.- Returns:
- This builder.
-
getClock
public Clock getClock()
Returns the clock used by the player.
-
setLooper
public TestExoPlayerBuilder setLooper(Looper looper)
Sets theLooper
to be used by the player.- Parameters:
looper
- TheLooper
to be used by the player.- Returns:
- This builder.
-
getLooper
@Nullable public Looper getLooper()
-
getMediaSourceFactory
@Nullable public MediaSourceFactory getMediaSourceFactory()
Returns theMediaSourceFactory
that will be used by the player, or null if noMediaSourceFactory
has been set yet and no default is available.
-
setMediaSourceFactory
public TestExoPlayerBuilder setMediaSourceFactory(MediaSourceFactory mediaSourceFactory)
Sets theMediaSourceFactory
to be used by the player.- Parameters:
mediaSourceFactory
- TheMediaSourceFactory
to be used by the player.- Returns:
- This builder.
-
setSeekBackIncrementMs
public TestExoPlayerBuilder setSeekBackIncrementMs(long seekBackIncrementMs)
Sets the seek back increment to be used by the player.- Parameters:
seekBackIncrementMs
- The seek back increment to be used by the player.- Returns:
- This builder.
-
getSeekBackIncrementMs
public long getSeekBackIncrementMs()
Returns the seek back increment used by the player.
-
setSeekForwardIncrementMs
public TestExoPlayerBuilder setSeekForwardIncrementMs(long seekForwardIncrementMs)
Sets the seek forward increment to be used by the player.- Parameters:
seekForwardIncrementMs
- The seek forward increment to be used by the player.- Returns:
- This builder.
-
getSeekForwardIncrementMs
public long getSeekForwardIncrementMs()
Returns the seek forward increment used by the player.
-
build
public SimpleExoPlayer build()
Builds anSimpleExoPlayer
using the provided values or their defaults.
-
-