TestExoPlayerBuilder


@UnstableApi
public class TestExoPlayerBuilder


A builder of ExoPlayer instances for testing.

Summary

Public constructors

Public methods

ExoPlayer

Builds an ExoPlayer using the provided values or their defaults.

BandwidthMeter

Returns the bandwidth meter used by the player.

Clock

Returns the clock used by the player.

LoadControl

Returns the LoadControl that will be used by the player.

@Nullable Looper

Returns the Looper that will be used by the player, or null if no Looper has been set yet and no default is available.

long

Returns the max seek to previous position used by the player.

@Nullable MediaSource.Factory

Returns the MediaSource.Factory that will be used by the player, or null if no has been set yet and no default is available.

@Nullable Renderer[]

Returns the Renderers that have been set with setRenderers or null if no Renderers have been explicitly set.

@Nullable RenderersFactory

Returns the RenderersFactory that has been set with setRenderersFactory or null if no factory has been explicitly set.

long

Returns the seek back increment used by the player.

long

Returns the seek forward increment used by the player.

DefaultTrackSelector

Returns the track selector used by the player.

boolean

Returns whether the player will use lazy preparation.

TestExoPlayerBuilder

Sets the BandwidthMeter.

TestExoPlayerBuilder

Sets the Clock to be used by the player.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setDeviceVolumeControlEnabled(boolean deviceVolumeControlEnabled)

Sets the variable controlling player's ability to get/set device volume.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setDynamicSchedulingEnabled(boolean dynamicSchedulingEnabled)

See experimentalSetDynamicSchedulingEnabled for details.

TestExoPlayerBuilder

Sets a LoadControl to be used by the player.

TestExoPlayerBuilder

Sets the Looper to be used by the player.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)

Sets the max seek to previous position, in milliseconds, to be used by the player.

TestExoPlayerBuilder

Sets the MediaSource.Factory to be used by the player.

TestExoPlayerBuilder

Sets the preload configuration.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setRenderers(Renderer[] renderers)

Sets the Renderers.

TestExoPlayerBuilder

Sets the RenderersFactory.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setSeekBackIncrementMs(long seekBackIncrementMs)

Sets the seek back increment to be used by the player.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setSeekForwardIncrementMs(long seekForwardIncrementMs)

Sets the seek forward increment to be used by the player.

TestExoPlayerBuilder

Sets the SuitableOutputChecker to check the suitability of the selected outputs for playback.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setSuppressPlaybackOnUnsuitableOutput(
    boolean suppressPlaybackOnUnsuitableOutput
)

See setSuppressPlaybackOnUnsuitableOutput for details.

TestExoPlayerBuilder

Sets a DefaultTrackSelector.

TestExoPlayerBuilder
@CanIgnoreReturnValue
setUseLazyPreparation(boolean useLazyPreparation)

Sets whether to use lazy preparation.

Public fields

bandwidthMeter

public BandwidthMeter bandwidthMeter

clock

public Clock clock

loadControl

public LoadControl loadControl

mediaSourceFactory

public @Nullable MediaSource.Factory mediaSourceFactory

renderers

public @Nullable Renderer[] renderers

renderersFactory

public @Nullable RenderersFactory renderersFactory

seekBackIncrementMs

public long seekBackIncrementMs

seekForwardIncrementMs

public long seekForwardIncrementMs

trackSelector

public DefaultTrackSelector trackSelector

useLazyPreparation

public boolean useLazyPreparation

Public constructors

TestExoPlayerBuilder

public TestExoPlayerBuilder(Context context)

Public methods

build

public ExoPlayer build()

Builds an ExoPlayer using the provided values or their defaults.

getBandwidthMeter

public BandwidthMeter getBandwidthMeter()

Returns the bandwidth meter used by the player.

getClock

public Clock getClock()

Returns the clock used by the player.

getLoadControl

public LoadControl getLoadControl()

Returns the LoadControl that will be used by the player.

getLooper

public @Nullable Looper getLooper()

Returns the Looper that will be used by the player, or null if no Looper has been set yet and no default is available.

getMaxSeekToPreviousPosition

public long getMaxSeekToPreviousPosition()

Returns the max seek to previous position used by the player.

getMediaSourceFactory

public @Nullable MediaSource.Factory getMediaSourceFactory()

Returns the MediaSource.Factory that will be used by the player, or null if no has been set yet and no default is available.

getRenderers

public @Nullable Renderer[] getRenderers()

Returns the Renderers that have been set with setRenderers or null if no Renderers have been explicitly set. Note that these renderers may not be the ones used by the built player, for example if a Renderer factory has been set.

getRenderersFactory

public @Nullable RenderersFactory getRenderersFactory()

Returns the RenderersFactory that has been set with setRenderersFactory or null if no factory has been explicitly set.

getSeekBackIncrementMs

public long getSeekBackIncrementMs()

Returns the seek back increment used by the player.

getSeekForwardIncrementMs

public long getSeekForwardIncrementMs()

Returns the seek forward increment used by the player.

getTrackSelector

public DefaultTrackSelector getTrackSelector()

Returns the track selector used by the player.

getUseLazyPreparation

public boolean getUseLazyPreparation()

Returns whether the player will use lazy preparation.

setBandwidthMeter

@CanIgnoreReturnValue
public TestExoPlayerBuilder setBandwidthMeter(BandwidthMeter bandwidthMeter)

Sets the BandwidthMeter. The default value is a DefaultBandwidthMeter in its default configuration.

Parameters
BandwidthMeter bandwidthMeter

The BandwidthMeter to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setClock

@CanIgnoreReturnValue
public TestExoPlayerBuilder setClock(Clock clock)

Sets the Clock to be used by the player. The default value is an auto-advancing .

Parameters
Clock clock

A Clock to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setDeviceVolumeControlEnabled

@CanIgnoreReturnValue
public TestExoPlayerBuilder setDeviceVolumeControlEnabled(boolean deviceVolumeControlEnabled)

Sets the variable controlling player's ability to get/set device volume.

Parameters
boolean deviceVolumeControlEnabled

Whether the player can get/set device volume.

Returns
TestExoPlayerBuilder

This builder.

setDynamicSchedulingEnabled

@CanIgnoreReturnValue
public TestExoPlayerBuilder setDynamicSchedulingEnabled(boolean dynamicSchedulingEnabled)

See experimentalSetDynamicSchedulingEnabled for details.

Parameters
boolean dynamicSchedulingEnabled

Whether the player should enable dynamically schedule its playback loop for when Renderer progress can be made.

Returns
TestExoPlayerBuilder

This builder.

setLoadControl

@CanIgnoreReturnValue
public TestExoPlayerBuilder setLoadControl(LoadControl loadControl)

Sets a LoadControl to be used by the player. The default value is a .

Parameters
LoadControl loadControl

The LoadControl to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setLooper

@CanIgnoreReturnValue
public TestExoPlayerBuilder setLooper(Looper looper)

Sets the Looper to be used by the player.

Parameters
Looper looper

The Looper to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setMaxSeekToPreviousPositionMs

@CanIgnoreReturnValue
public TestExoPlayerBuilder setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs)

Sets the max seek to previous position, in milliseconds, to be used by the player.

Parameters
long maxSeekToPreviousPositionMs

The max seek to previous position to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setMediaSourceFactory

@CanIgnoreReturnValue
public TestExoPlayerBuilder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)

Sets the MediaSource.Factory to be used by the player.

Parameters
MediaSource.Factory mediaSourceFactory

The MediaSource.Factory to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setPreloadConfiguration

@CanIgnoreReturnValue
public TestExoPlayerBuilder setPreloadConfiguration(
    ExoPlayer.PreloadConfiguration preloadConfiguration
)

Sets the preload configuration.

setRenderers

@CanIgnoreReturnValue
public TestExoPlayerBuilder setRenderers(Renderer[] renderers)

Sets the Renderers. If not set, the player will use a FakeVideoRenderer and a FakeAudioRenderer. Setting the renderers is not allowed after a call to setRenderersFactory.

Parameters
Renderer[] renderers

A list of Renderers to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setRenderersFactory

@CanIgnoreReturnValue
public TestExoPlayerBuilder setRenderersFactory(RenderersFactory renderersFactory)

Sets the RenderersFactory. The default factory creates all renderers set by setRenderers. Setting the renderer factory is not allowed after a call to setRenderers.

Parameters
RenderersFactory renderersFactory

A RenderersFactory to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setSeekBackIncrementMs

@CanIgnoreReturnValue
public TestExoPlayerBuilder setSeekBackIncrementMs(long seekBackIncrementMs)

Sets the seek back increment to be used by the player.

Parameters
long seekBackIncrementMs

The seek back increment to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setSeekForwardIncrementMs

@CanIgnoreReturnValue
public TestExoPlayerBuilder setSeekForwardIncrementMs(long seekForwardIncrementMs)

Sets the seek forward increment to be used by the player.

Parameters
long seekForwardIncrementMs

The seek forward increment to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setSuitableOutputChecker

@CanIgnoreReturnValue
@RequiresApi(value = 35)
public TestExoPlayerBuilder setSuitableOutputChecker(SuitableOutputChecker suitableOutputChecker)

Sets the SuitableOutputChecker to check the suitability of the selected outputs for playback.

If this method is not called, the library uses a default implementation based on framework APIs.

Returns
TestExoPlayerBuilder

This builder.

setSuppressPlaybackOnUnsuitableOutput

@CanIgnoreReturnValue
public TestExoPlayerBuilder setSuppressPlaybackOnUnsuitableOutput(
    boolean suppressPlaybackOnUnsuitableOutput
)

See setSuppressPlaybackOnUnsuitableOutput for details.

Parameters
boolean suppressPlaybackOnUnsuitableOutput

Whether the player should suppress the playback when it is attempted on an unsuitable output.

Returns
TestExoPlayerBuilder

This builder.

setTrackSelector

@CanIgnoreReturnValue
public TestExoPlayerBuilder setTrackSelector(DefaultTrackSelector trackSelector)

Sets a DefaultTrackSelector. The default value is a DefaultTrackSelector in its initial configuration.

Parameters
DefaultTrackSelector trackSelector

The DefaultTrackSelector to be used by the player.

Returns
TestExoPlayerBuilder

This builder.

setUseLazyPreparation

@CanIgnoreReturnValue
public TestExoPlayerBuilder setUseLazyPreparation(boolean useLazyPreparation)

Sets whether to use lazy preparation.

Parameters
boolean useLazyPreparation

Whether to use lazy preparation.

Returns
TestExoPlayerBuilder

This builder.