DefaultPreloadManager.Builder


public final class DefaultPreloadManager.Builder extends BasePreloadManager.BuilderBase


A builder for DefaultPreloadManager instances.

Summary

Public constructors

Builder(
    Context context,
    TargetPreloadStatusControl<IntegerDefaultPreloadManager.PreloadStatus> targetPreloadStatusControl
)

Creates a builder.

Public methods

DefaultPreloadManager

Builds a DefaultPreloadManager instance.

ExoPlayer

Builds an ExoPlayer.

ExoPlayer

Builds an ExoPlayer with an ExoPlayer.Builder passed in.

DefaultPreloadManager.Builder

Sets the BandwidthMeter that will be used by the built DefaultPreloadManager and ExoPlayer.

DefaultPreloadManager.Builder

Sets the Cache that will be used for caching the media items.

DefaultPreloadManager.Builder

Sets an Executor used to cache data.

DefaultPreloadManager.Builder

Sets the Clock that will be used the DefaultPreloadManager.

DefaultPreloadManager.Builder

Sets the LoadControl that will be used by the built DefaultPreloadManager and ExoPlayer.

DefaultPreloadManager.Builder

Sets the MediaSource.Factory that will be used by the built DefaultPreloadManager and ExoPlayer.

DefaultPreloadManager.Builder

Sets the Looper that will be used for preload and playback.

DefaultPreloadManager.Builder

Sets the RenderersFactory that will be used by the built DefaultPreloadManager and ExoPlayer.

DefaultPreloadManager.Builder

Sets the TrackSelector.Factory that will be used by the built DefaultPreloadManager and ExoPlayer.

Public constructors

Builder

public Builder(
    Context context,
    TargetPreloadStatusControl<IntegerDefaultPreloadManager.PreloadStatus> targetPreloadStatusControl
)

Creates a builder.

Public methods

build

public DefaultPreloadManager build()

Builds a DefaultPreloadManager instance.

Throws
java.lang.IllegalStateException

If this method has already been called.

buildExoPlayer

public ExoPlayer buildExoPlayer()

Builds an ExoPlayer.

See buildExoPlayer for the list of values populated on and resulting from this builder that the built ExoPlayer uses.

For the other configurations than above, the built ExoPlayer uses the default values, see Builder for the list of default values.

Returns
ExoPlayer

An ExoPlayer instance.

buildExoPlayer

public ExoPlayer buildExoPlayer(ExoPlayer.Builder exoPlayerBuilder)

Builds an ExoPlayer with an ExoPlayer.Builder passed in.

The built ExoPlayer uses the following values populated on and resulting from this builder:

For the other configurations than above, the built ExoPlayer uses the values from the passed ExoPlayer.Builder.

Parameters
ExoPlayer.Builder exoPlayerBuilder

An ExoPlayer.Builder that is used to build the ExoPlayer.

Returns
ExoPlayer

An ExoPlayer instance.

setBandwidthMeter

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setBandwidthMeter(BandwidthMeter bandwidthMeter)

Sets the BandwidthMeter that will be used by the built DefaultPreloadManager and ExoPlayer.

The default is a DefaultBandwidthMeter.

Parameters
BandwidthMeter bandwidthMeter

A BandwidthMeter.

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called.

setCache

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setCache(@Nullable Cache cache)

Sets the Cache that will be used for caching the media items.

The default is null. If an app will return specifiedRangeCached or specifiedRangeCached in its implementation of TargetPreloadStatusControl, a non-null instance must be passed.

Parameters
@Nullable Cache cache

A Cache.

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called.

setCachingExecutor

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setCachingExecutor(Executor executor)

Sets an Executor used to cache data.

The default is Runnable::run, which will cause each caching task to download data on a separate download thread. Passing an Executor that uses multiple threads will speed up caching tasks that can be split into smaller parts for parallel execution.

Parameters
Executor executor

An Executor.

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called.

setClock

@VisibleForTesting
@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setClock(Clock clock)

Sets the Clock that will be used the DefaultPreloadManager. Should only be set for testing purposes.

Returns
DefaultPreloadManager.Builder

This builder.

setLoadControl

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setLoadControl(LoadControl loadControl)

Sets the LoadControl that will be used by the built DefaultPreloadManager and ExoPlayer.

The default is a DefaultLoadControl.

Parameters
LoadControl loadControl

A LoadControl.

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called.

setMediaSourceFactory

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory)

Sets the MediaSource.Factory that will be used by the built DefaultPreloadManager and ExoPlayer.

The default is a DefaultMediaSourceFactory.

Parameters
MediaSource.Factory mediaSourceFactory

A MediaSource.Factory

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called.

setPreloadLooper

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setPreloadLooper(Looper preloadLooper)

Sets the Looper that will be used for preload and playback.

The backing thread should run with priority THREAD_PRIORITY_AUDIO and should handle messages within 10ms.

The default is a looper that is associated with a new thread created internally.

Parameters
Looper preloadLooper

A Looper.

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called, or when the main looper is passed in.

setRenderersFactory

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setRenderersFactory(RenderersFactory renderersFactory)

Sets the RenderersFactory that will be used by the built DefaultPreloadManager and ExoPlayer.

The default is a DefaultRenderersFactory.

Parameters
RenderersFactory renderersFactory

A RenderersFactory.

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called.

setTrackSelectorFactory

@CanIgnoreReturnValue
public DefaultPreloadManager.Builder setTrackSelectorFactory(TrackSelector.Factory trackSelectorFactory)

Sets the TrackSelector.Factory that will be used by the built DefaultPreloadManager and ExoPlayer.

The default is a TrackSelector.Factory that always creates a new DefaultTrackSelector.

Parameters
TrackSelector.Factory trackSelectorFactory

A TrackSelector.Factory.

Returns
DefaultPreloadManager.Builder

This builder.

Throws
java.lang.IllegalStateException

If build, buildExoPlayer or buildExoPlayer has already been called.