PreCacheHelper.Factory


public final class PreCacheHelper.Factory


A factory for PreCacheHelper.

Summary

Public constructors

Factory(Context context, Cache cache, Looper preCacheLooper)

Creates a Factory.

Factory(
    Cache cache,
    DataSource.Factory upstreamDataSourceFactory,
    RenderersFactory renderersFactory,
    Looper preCacheLooper
)

Creates a Factory.

Factory(
    Context context,
    Cache cache,
    RenderersFactory renderersFactory,
    Looper preCacheLooper
)

Creates a Factory.

Factory(
    Context context,
    Cache cache,
    DataSource.Factory upstreamDataSourceFactory,
    Looper preCacheLooper
)

Creates a Factory.

Public methods

PreCacheHelper
create(MediaItem mediaItem)

Creates a PreCacheHelper instance.

PreCacheHelper.Factory

Sets an Executor used to download data.

PreCacheHelper.Factory

Sets the Listener.

PreCacheHelper.Factory

Sets a TrackSelectionParameters for selecting tracks for pre-caching.

Public constructors

Factory

public Factory(Context context, Cache cache, Looper preCacheLooper)

Creates a Factory.

Parameters
Context context

The Context.

Cache cache

The Cache instance that will be used.

Looper preCacheLooper

The Looper that operates the pre-caching flow. Note that this looper is not responsible for downloading the data.

Factory

public Factory(
    Cache cache,
    DataSource.Factory upstreamDataSourceFactory,
    RenderersFactory renderersFactory,
    Looper preCacheLooper
)

Creates a Factory.

Parameters
Cache cache

The Cache instance that will be used.

DataSource.Factory upstreamDataSourceFactory

The upstream DataSource.Factory for reading data not in the cache.

RenderersFactory renderersFactory

The RenderersFactory creating the renderers for which tracks are selected.

Looper preCacheLooper

The Looper that operates the pre-caching flow. Note that this looper is not responsible for downloading the data.

Factory

public Factory(
    Context context,
    Cache cache,
    RenderersFactory renderersFactory,
    Looper preCacheLooper
)

Creates a Factory.

Parameters
Context context

The Context.

Cache cache

The Cache instance that will be used.

RenderersFactory renderersFactory

The RenderersFactory creating the renderers for which tracks are selected.

Looper preCacheLooper

The Looper that operates the pre-caching flow. Note that this looper is not responsible for downloading the data.

Factory

public Factory(
    Context context,
    Cache cache,
    DataSource.Factory upstreamDataSourceFactory,
    Looper preCacheLooper
)

Creates a Factory.

Parameters
Context context

The Context.

Cache cache

The Cache instance that will be used.

DataSource.Factory upstreamDataSourceFactory

The upstream DataSource.Factory for reading data not in the cache.

Looper preCacheLooper

The Looper that operates the pre-caching flow. Note that this looper is not responsible for downloading the data.

Public methods

create

public PreCacheHelper create(MediaItem mediaItem)

Creates a PreCacheHelper instance.

Parameters
MediaItem mediaItem

The MediaItem to pre-cache.

setDownloadExecutor

@CanIgnoreReturnValue
public PreCacheHelper.Factory setDownloadExecutor(Executor downloadExecutor)

Sets an Executor used to download data.

The default is a single threaded scheduled executor.

Passing Runnable::run will cause each download task to download data on its own thread. Passing an Executor that uses multiple threads will speed up download tasks that can be split into smaller parts for parallel execution.

Returns
PreCacheHelper.Factory

This factory, for convenience.

setListener

@CanIgnoreReturnValue
public PreCacheHelper.Factory setListener(@Nullable PreCacheHelper.Listener listener)

Sets the Listener.

Returns
PreCacheHelper.Factory

This factory, for convenience.

setTrackSelectionParameters

@CanIgnoreReturnValue
public PreCacheHelper.Factory setTrackSelectionParameters(
    TrackSelectionParameters trackSelectionParameters
)

Sets a TrackSelectionParameters for selecting tracks for pre-caching.

The default is DEFAULT.

This is only used for adaptive streams.

Returns
PreCacheHelper.Factory

This factory, for convenience.