Class DefaultHttpDataSource.Factory
- java.lang.Object
-
- com.google.android.exoplayer2.upstream.DefaultHttpDataSource.Factory
-
- All Implemented Interfaces:
DataSource.Factory
,HttpDataSource.Factory
- Enclosing class:
- DefaultHttpDataSource
public static final class DefaultHttpDataSource.Factory extends Object implements HttpDataSource.Factory
DataSource.Factory
forDefaultHttpDataSource
instances.
-
-
Constructor Summary
Constructors Constructor Description Factory()
Creates an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultHttpDataSource
createDataSource()
Creates aDataSource
instance.DefaultHttpDataSource.Factory
setAllowCrossProtocolRedirects(boolean allowCrossProtocolRedirects)
Sets whether to allow cross protocol redirects.DefaultHttpDataSource.Factory
setConnectTimeoutMs(int connectTimeoutMs)
Sets the connect timeout, in milliseconds.DefaultHttpDataSource.Factory
setContentTypePredicate(Predicate<String> contentTypePredicate)
Sets a content typePredicate
.DefaultHttpDataSource.Factory
setDefaultRequestProperties(Map<String,String> defaultRequestProperties)
Sets the default request headers forHttpDataSource
instances created by the factory.DefaultHttpDataSource.Factory
setKeepPostFor302Redirects(boolean keepPostFor302Redirects)
Sets whether we should keep the POST method and body when we have HTTP 302 redirects for a POST request.DefaultHttpDataSource.Factory
setReadTimeoutMs(int readTimeoutMs)
Sets the read timeout, in milliseconds.DefaultHttpDataSource.Factory
setTransferListener(TransferListener transferListener)
Sets theTransferListener
that will be used.DefaultHttpDataSource.Factory
setUserAgent(String userAgent)
Sets the user agent that will be used.
-
-
-
Method Detail
-
setDefaultRequestProperties
@CanIgnoreReturnValue public final DefaultHttpDataSource.Factory setDefaultRequestProperties(Map<String,String> defaultRequestProperties)
Description copied from interface:HttpDataSource.Factory
Sets the default request headers forHttpDataSource
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 thedefaultRequestProperties
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 interfaceHttpDataSource.Factory
- Parameters:
defaultRequestProperties
- The default request properties.- Returns:
- This factory.
-
setUserAgent
@CanIgnoreReturnValue public DefaultHttpDataSource.Factory setUserAgent(@Nullable String userAgent)
Sets the user agent that will be used.The default is
null
, which causes the default user agent of the underlying platform to be used.- Parameters:
userAgent
- The user agent that will be used, ornull
to use the default user agent of the underlying platform.- Returns:
- This factory.
-
setConnectTimeoutMs
@CanIgnoreReturnValue public DefaultHttpDataSource.Factory setConnectTimeoutMs(int connectTimeoutMs)
Sets the connect timeout, in milliseconds.The default is
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS
.- Parameters:
connectTimeoutMs
- The connect timeout, in milliseconds, that will be used.- Returns:
- This factory.
-
setReadTimeoutMs
@CanIgnoreReturnValue public DefaultHttpDataSource.Factory setReadTimeoutMs(int readTimeoutMs)
Sets the read timeout, in milliseconds.The default is
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS
.- Parameters:
readTimeoutMs
- The connect timeout, in milliseconds, that will be used.- Returns:
- This factory.
-
setAllowCrossProtocolRedirects
@CanIgnoreReturnValue public DefaultHttpDataSource.Factory setAllowCrossProtocolRedirects(boolean allowCrossProtocolRedirects)
Sets whether to allow cross protocol redirects.The default is
false
.- Parameters:
allowCrossProtocolRedirects
- Whether to allow cross protocol redirects.- Returns:
- This factory.
-
setContentTypePredicate
@CanIgnoreReturnValue public DefaultHttpDataSource.Factory setContentTypePredicate(@Nullable Predicate<String> contentTypePredicate)
Sets a content typePredicate
. If a content type is rejected by the predicate then aHttpDataSource.InvalidContentTypeException
is thrown fromDefaultHttpDataSource.open(DataSpec)
.The default is
null
.- Parameters:
contentTypePredicate
- The content typePredicate
, ornull
to clear a predicate that was previously set.- Returns:
- This factory.
-
setTransferListener
@CanIgnoreReturnValue public DefaultHttpDataSource.Factory setTransferListener(@Nullable TransferListener transferListener)
Sets theTransferListener
that will be used.The default is
null
.- Parameters:
transferListener
- The listener that will be used.- Returns:
- This factory.
-
setKeepPostFor302Redirects
@CanIgnoreReturnValue public DefaultHttpDataSource.Factory setKeepPostFor302Redirects(boolean keepPostFor302Redirects)
Sets whether we should keep the POST method and body when we have HTTP 302 redirects for a POST request.
-
createDataSource
public DefaultHttpDataSource createDataSource()
Description copied from interface:DataSource.Factory
Creates aDataSource
instance.- Specified by:
createDataSource
in interfaceDataSource.Factory
- Specified by:
createDataSource
in interfaceHttpDataSource.Factory
-
-