docs/doc/reference/com/google/android/exoplayer2/upstream/cache/CacheDataSource.Factory.html
Package com.google.android.exoplayer2.upstream.cache
All Implemented Interfaces:DataSource.FactoryEnclosing class:CacheDataSource
public static final classCacheDataSource.Factoryextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[DataSource.Factory](../DataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")
DataSource.Factory for CacheDataSource instances.
Constructors | Constructor | Description |
| --- | --- |
| Factory() | |
All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| CacheDataSource | createDataSource() |
Creates a DataSource instance.
|
| CacheDataSource | createDataSourceForDownloading() |
Returns an instance suitable for downloading content.
|
| CacheDataSource | createDataSourceForRemovingDownload() |
Returns an instance suitable for reading cached content as part of removing a download.
|
| Cache | getCache() |
Returns the cache that will be used, or null if setCache(com.google.android.exoplayer2.upstream.cache.Cache) has yet to be called.
|
| CacheKeyFactory | getCacheKeyFactory() |
Returns the CacheKeyFactory that will be used.
|
| PriorityTaskManager | getUpstreamPriorityTaskManager() |
Returns the PriorityTaskManager that will bs used when requesting data from upstream, or null if there is none.
|
| CacheDataSource.Factory | setCache(Cache cache) |
Sets the cache that will be used.
|
| CacheDataSource.Factory | setCacheKeyFactory(CacheKeyFactory cacheKeyFactory) |
Sets the CacheKeyFactory.
|
| CacheDataSource.Factory | setCacheReadDataSourceFactory(DataSource.Factory cacheReadDataSourceFactory) |
Sets the DataSource.Factory for DataSources for reading from the cache.
|
| CacheDataSource.Factory | setCacheWriteDataSinkFactory(DataSink.Factory cacheWriteDataSinkFactory) |
Sets the DataSink.Factory for generating DataSinks for writing data to the cache.
|
| CacheDataSource.Factory | setEventListener(CacheDataSource.EventListener eventListener) |
Sets the {link EventListener} to which events are delivered.
|
| CacheDataSource.Factory | setFlags(@com.google.android.exoplayer2.upstream.cache.CacheDataSource.Flags int flags) |
Sets the CacheDataSource.Flags.
|
| CacheDataSource.Factory | setUpstreamDataSourceFactory(DataSource.Factory upstreamDataSourceFactory) |
Sets the DataSource.Factory for upstream DataSources, which are used to read data in the case of a cache miss.
|
| CacheDataSource.Factory | setUpstreamPriority(int upstreamPriority) |
Sets the priority to use when requesting data from upstream.
|
| CacheDataSource.Factory | setUpstreamPriorityTaskManager(PriorityTaskManager upstreamPriorityTaskManager) |
Sets an optional PriorityTaskManager to use when requesting data from upstream.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public Factory()
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setCache([Cache](Cache.html "interface in com.google.android.exoplayer2.upstream.cache")cache)
Sets the cache that will be used.
Must be called before the factory is used.
Parameters:cache - The cache that will be used.Returns:This factory.
-
@Nullable
public[Cache](Cache.html "interface in com.google.android.exoplayer2.upstream.cache")getCache()
Returns the cache that will be used, or null if setCache(com.google.android.exoplayer2.upstream.cache.Cache) has yet to be called.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setCacheReadDataSourceFactory([DataSource.Factory](../DataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")cacheReadDataSourceFactory)
Sets the DataSource.Factory for DataSources for reading from the cache.
The default is a FileDataSource.Factory in its default configuration.
Parameters:cacheReadDataSourceFactory - The DataSource.Factory for reading from the cache.Returns:This factory.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setCacheWriteDataSinkFactory(@Nullable[DataSink.Factory](../DataSink.Factory.html "interface in com.google.android.exoplayer2.upstream")cacheWriteDataSinkFactory)
Sets the DataSink.Factory for generating DataSinks for writing data to the cache. Passing null causes the cache to be read-only.
The default is a CacheDataSink.Factory in its default configuration.
Parameters:cacheWriteDataSinkFactory - The DataSink.Factory for generating DataSinks for writing data to the cache, or null to disable writing.Returns:This factory.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setCacheKeyFactory([CacheKeyFactory](CacheKeyFactory.html "interface in com.google.android.exoplayer2.upstream.cache")cacheKeyFactory)
Sets the CacheKeyFactory.
The default is CacheKeyFactory.DEFAULT.
Parameters:cacheKeyFactory - The CacheKeyFactory.Returns:This factory.
-
public[CacheKeyFactory](CacheKeyFactory.html "interface in com.google.android.exoplayer2.upstream.cache")getCacheKeyFactory()
Returns the CacheKeyFactory that will be used.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setUpstreamDataSourceFactory(@Nullable[DataSource.Factory](../DataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")upstreamDataSourceFactory)
Sets the DataSource.Factory for upstream DataSources, which are used to read data in the case of a cache miss.
The default is null, and so this method must be called before the factory is used in order for data to be read from upstream in the case of a cache miss.
Parameters:upstreamDataSourceFactory - The upstream DataSource for reading data not in the cache, or null to cause failure in the case of a cache miss.Returns:This factory.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setUpstreamPriorityTaskManager(@Nullable[PriorityTaskManager](../../util/PriorityTaskManager.html "class in com.google.android.exoplayer2.util")upstreamPriorityTaskManager)
Sets an optional PriorityTaskManager to use when requesting data from upstream.
If set, reads from the upstream DataSource will only be allowed to proceed if there are no higher priority tasks registered to the PriorityTaskManager. If there exists a higher priority task then PriorityTaskManager.PriorityTooLowException will be thrown instead.
Note that requests to CacheDataSource instances are intended to be used as parts of (possibly larger) tasks that are registered with the PriorityTaskManager, and hence CacheDataSource does not register a task by itself. This must be done by the surrounding code that uses the CacheDataSource instances.
The default is null.
Parameters:upstreamPriorityTaskManager - The upstream PriorityTaskManager.Returns:This factory.
-
@Nullable
public[PriorityTaskManager](../../util/PriorityTaskManager.html "class in com.google.android.exoplayer2.util")getUpstreamPriorityTaskManager()
Returns the PriorityTaskManager that will bs used when requesting data from upstream, or null if there is none.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setUpstreamPriority(int upstreamPriority)
Sets the priority to use when requesting data from upstream. The priority is only used if a PriorityTaskManager is set by calling setUpstreamPriorityTaskManager(com.google.android.exoplayer2.util.PriorityTaskManager).
The default is C.PRIORITY_PLAYBACK.
Parameters:upstreamPriority - The priority to use when requesting data from upstream.Returns:This factory.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setFlags(@com.google.android.exoplayer2.upstream.cache.CacheDataSource.Flags int flags)
Sets the CacheDataSource.Flags.
The default is 0.
Parameters:flags - The CacheDataSource.Flags.Returns:This factory.
-
@CanIgnoreReturnValue
public[CacheDataSource.Factory](CacheDataSource.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setEventListener(@Nullable[CacheDataSource.EventListener](CacheDataSource.EventListener.html "interface in com.google.android.exoplayer2.upstream.cache")eventListener)
Sets the {link EventListener} to which events are delivered.
The default is null.
Parameters:eventListener - The CacheDataSource.EventListener.Returns:This factory.
-
public[CacheDataSource](CacheDataSource.html "class in com.google.android.exoplayer2.upstream.cache")createDataSource()
Description copied from interface: DataSource.Factory
Creates a DataSource instance.
Specified by:createDataSource in interface DataSource.Factory
-
public[CacheDataSource](CacheDataSource.html "class in com.google.android.exoplayer2.upstream.cache")createDataSourceForDownloading()
Returns an instance suitable for downloading content. The created instance is equivalent to one that would be created by createDataSource(), except:
- The CacheDataSource.FLAG_BLOCK_ON_CACHE is always set.
- The task priority is overridden to be C.PRIORITY_DOWNLOAD.
Returns:An instance suitable for downloading content.
-
public[CacheDataSource](CacheDataSource.html "class in com.google.android.exoplayer2.upstream.cache")createDataSourceForRemovingDownload()
Returns an instance suitable for reading cached content as part of removing a download. The created instance is equivalent to one that would be created by createDataSource(), except:
- The upstream is overridden to be null, since when removing content we don't want to request anything that's not already cached.
- The CacheDataSource.FLAG_BLOCK_ON_CACHE is always set.
- The task priority is overridden to be C.PRIORITY_DOWNLOAD.
Returns:An instance suitable for reading cached content as part of removing a download.