Back to Exoplayer

CacheDataSink.Factory (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/upstream/cache/CacheDataSink.Factory.html

latest4.3 KB
Original Source

Package com.google.android.exoplayer2.upstream.cache

Class CacheDataSink.Factory

  • java.lang.Object

    • com.google.android.exoplayer2.upstream.cache.CacheDataSink.Factory
  • All Implemented Interfaces:DataSink.FactoryEnclosing class:CacheDataSink


public static final classCacheDataSink.Factoryextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[DataSink.Factory](../DataSink.Factory.html "interface in com.google.android.exoplayer2.upstream")

DataSink.Factory for CacheDataSink instances.

Constructor Summary

Constructors | Constructor | Description | | --- | --- | | Factory() | Creates an instance. |

Method Summary

All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description | | --- | --- | --- | | DataSink | createDataSink() | Creates a DataSink instance. | | CacheDataSink.Factory | setBufferSize​(int bufferSize) | Sets the size of an in-memory buffer used when writing to a cache file. | | CacheDataSink.Factory | setCache​(Cache cache) | Sets the cache to which data will be written. | | CacheDataSink.Factory | setFragmentSize​(long fragmentSize) | Sets the cache file fragment size. |

- 

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

- 

Factory

public Factory()

Creates an instance.

Method Detail

- 

setCache

@CanIgnoreReturnValue
public[CacheDataSink.Factory](CacheDataSink.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 to which data will be written.

Must be called before the factory is used.

Parameters:cache - The cache to which data will be written.Returns:This factory.

- 

setFragmentSize

@CanIgnoreReturnValue
public[CacheDataSink.Factory](CacheDataSink.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setFragmentSize​(long fragmentSize)

Sets the cache file fragment size. For requests that should be fragmented into multiple cache files, this is the maximum size of a cache file in bytes. If set to C.LENGTH_UNSET then no fragmentation will occur. Using a small value allows for finer-grained cache eviction policies, at the cost of increased overhead both on the cache implementation and the file system. Values under (2 * 1024 * 1024) are not recommended.

The default value is CacheDataSink.DEFAULT_FRAGMENT_SIZE.

Parameters:fragmentSize - The fragment size in bytes, or C.LENGTH_UNSET to disable fragmentation.Returns:This factory.

- 

setBufferSize

@CanIgnoreReturnValue
public[CacheDataSink.Factory](CacheDataSink.Factory.html "class in com.google.android.exoplayer2.upstream.cache")setBufferSize​(int bufferSize)

Sets the size of an in-memory buffer used when writing to a cache file. A zero or negative value disables buffering.

The default value is CacheDataSink.DEFAULT_BUFFER_SIZE.

Parameters:bufferSize - The buffer size in bytes.Returns:This factory.

- 

createDataSink

public[DataSink](../DataSink.html "interface in com.google.android.exoplayer2.upstream")createDataSink()

Description copied from interface: DataSink.Factory

Creates a DataSink instance. Specified by:createDataSink in interface DataSink.Factory