public final class

DefaultHttpDataSource.Factory

extends java.lang.Object

implements HttpDataSource.Factory

 java.lang.Object

↳androidx.media3.datasource.DefaultHttpDataSource.Factory

Overview

DataSource.Factory for DefaultHttpDataSource instances.

Summary

Constructors
publicFactory()

Creates an instance.

Methods
public DefaultHttpDataSourcecreateDataSource()

public DefaultHttpDataSource.FactorysetAllowCrossProtocolRedirects(boolean allowCrossProtocolRedirects)

Sets whether to allow cross protocol redirects.

public DefaultHttpDataSource.FactorysetConnectTimeoutMs(int connectTimeoutMs)

Sets the connect timeout, in milliseconds.

public DefaultHttpDataSource.FactorysetContentTypePredicate(<any> contentTypePredicate)

Sets a content type .

public DefaultHttpDataSource.FactorysetCrossProtocolRedirectsForceOriginal(boolean crossProtocolRedirectsForceOriginal)

Sets whether cross protocol redirects should be forced to follow original protocol.

public DefaultHttpDataSource.FactorysetDefaultRequestProperties(java.util.Map<java.lang.String, java.lang.String> defaultRequestProperties)

public DefaultHttpDataSource.FactorysetKeepPostFor302Redirects(boolean keepPostFor302Redirects)

Sets whether we should keep the POST method and body when we have HTTP 302 redirects for a POST request.

public DefaultHttpDataSource.FactorysetReadTimeoutMs(int readTimeoutMs)

Sets the read timeout, in milliseconds.

public DefaultHttpDataSource.FactorysetTransferListener(TransferListener transferListener)

Sets the TransferListener that will be used.

public DefaultHttpDataSource.FactorysetUserAgent(java.lang.String userAgent)

Sets the user agent that will be used.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Factory()

Creates an instance.

Methods

public DefaultHttpDataSource.Factory setDefaultRequestProperties(java.util.Map<java.lang.String, java.lang.String> defaultRequestProperties)

public DefaultHttpDataSource.Factory setUserAgent(java.lang.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, or null to use the default user agent of the underlying platform.

Returns:

This factory.

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.

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.

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.

public DefaultHttpDataSource.Factory setCrossProtocolRedirectsForceOriginal(boolean crossProtocolRedirectsForceOriginal)

Sets whether cross protocol redirects should be forced to follow original protocol. This should only be set if allowCrossProtocolRedirects is false.

The default is false.

Parameters:

crossProtocolRedirectsForceOriginal: Whether to force original protocol.

Returns:

This factory.

public DefaultHttpDataSource.Factory setContentTypePredicate(<any> contentTypePredicate)

Sets a content type . If a content type is rejected by the predicate then a HttpDataSource.InvalidContentTypeException is thrown from DefaultHttpDataSource.open(DataSpec).

The default is null.

Parameters:

contentTypePredicate: The content type , or null to clear a predicate that was previously set.

Returns:

This factory.

public DefaultHttpDataSource.Factory setTransferListener(TransferListener 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 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.

public DefaultHttpDataSource createDataSource()