docs/doc/reference/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.Factory.html
Package com.google.android.exoplayer2.ext.okhttp
All Implemented Interfaces:DataSource.Factory, HttpDataSource.FactoryEnclosing class:OkHttpDataSource
public static final classOkHttpDataSource.Factoryextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")implements[HttpDataSource.Factory](../../upstream/HttpDataSource.Factory.html "interface in com.google.android.exoplayer2.upstream")
DataSource.Factory for OkHttpDataSource instances.
Constructors | Constructor | Description |
| --- | --- |
| Factory(okhttp3.Call.Factory callFactory) |
Creates an instance.
|
All Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| OkHttpDataSource | createDataSource() |
Creates a DataSource instance.
|
| OkHttpDataSource.Factory | setCacheControl(okhttp3.CacheControl cacheControl) |
Sets the CacheControl that will be used.
|
| OkHttpDataSource.Factory | setContentTypePredicate(Predicate<String> contentTypePredicate) |
Sets a content type Predicate.
|
| OkHttpDataSource.Factory | setDefaultRequestProperties(Map<String,String> defaultRequestProperties) |
Sets the default request headers for HttpDataSource instances created by the factory.
|
| OkHttpDataSource.Factory | setTransferListener(TransferListener transferListener) |
Sets the TransferListener that will be used.
|
| OkHttpDataSource.Factory | setUserAgent(String userAgent) |
Sets the user agent that will be used.
|
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public Factory(okhttp3.Call.Factory callFactory)
Creates an instance.
Parameters:callFactory - A Call.Factory (typically an OkHttpClient) for use by the sources created by the factory.
-
@CanIgnoreReturnValue
public final[OkHttpDataSource.Factory](OkHttpDataSource.Factory.html "class in com.google.android.exoplayer2.ext.okhttp")setDefaultRequestProperties([Map](https://developer.android.com/reference/java/util/Map.html "class or interface in java.util")<[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang"),[String](https://developer.android.com/reference/java/lang/String.html?is-external=true "class or interface in java.lang")> defaultRequestProperties)
Description copied from interface: HttpDataSource.Factory
Sets the default request headers for HttpDataSource instances created by the factory.
The new request properties will be used for future requests made by HttpDataSources created by the factory, including instances that have already been created. Modifying the defaultRequestProperties map after a call to this method will have no effect, and so it's necessary to call this method again each time the request properties need to be updated.
Specified by:setDefaultRequestProperties in interface HttpDataSource.FactoryParameters:defaultRequestProperties - The default request properties.Returns:This factory.
-
@CanIgnoreReturnValue
public[OkHttpDataSource.Factory](OkHttpDataSource.Factory.html "class in com.google.android.exoplayer2.ext.okhttp")setUserAgent(@Nullable[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")userAgent)
Sets the user agent that will be used.
The default is null, which causes the default user agent of the underlying OkHttpClient to be used.
Parameters:userAgent - The user agent that will be used, or null to use the default user agent of the underlying OkHttpClient.Returns:This factory.
-
@CanIgnoreReturnValue
public[OkHttpDataSource.Factory](OkHttpDataSource.Factory.html "class in com.google.android.exoplayer2.ext.okhttp")setCacheControl(@Nullable
okhttp3.CacheControl cacheControl)
Sets the CacheControl that will be used.
The default is null.
Parameters:cacheControl - The cache control that will be used.Returns:This factory.
-
@CanIgnoreReturnValue
public[OkHttpDataSource.Factory](OkHttpDataSource.Factory.html "class in com.google.android.exoplayer2.ext.okhttp")setContentTypePredicate(@Nullable[Predicate](https://guava.dev/releases/31.1-android/api/docs/com/google/common/base/Predicate.html?is-external=true "class or interface in com.google.common.base")<[String](https://developer.android.com/reference/java/lang/String.html "class or interface in java.lang")> contentTypePredicate)
Sets a content type Predicate. If a content type is rejected by the predicate then a HttpDataSource.InvalidContentTypeException is thrown from OkHttpDataSource.open(DataSpec).
The default is null.
Parameters:contentTypePredicate - The content type Predicate, or null to clear a predicate that was previously set.Returns:This factory.
-
@CanIgnoreReturnValue
public[OkHttpDataSource.Factory](OkHttpDataSource.Factory.html "class in com.google.android.exoplayer2.ext.okhttp")setTransferListener(@Nullable[TransferListener](../../upstream/TransferListener.html "interface in com.google.android.exoplayer2.upstream")transferListener)
Sets the TransferListener that will be used.
The default is null.
See DataSource.addTransferListener(TransferListener).
Parameters:transferListener - The listener that will be used.Returns:This factory.
-
public[OkHttpDataSource](OkHttpDataSource.html "class in com.google.android.exoplayer2.ext.okhttp")createDataSource()
Description copied from interface: DataSource.Factory
Creates a DataSource instance.
Specified by:createDataSource in interface DataSource.FactorySpecified by:createDataSource in interface HttpDataSource.Factory