public final class

OkHttpDataSource.Factory

extends java.lang.Object

implements HttpDataSource.Factory

 java.lang.Object

↳androidx.media3.datasource.okhttp.OkHttpDataSource.Factory

Overview

for OkHttpDataSource instances.

Summary

Constructors
publicFactory(Call.Factory callFactory)

Creates an instance.

Methods
public OkHttpDataSourcecreateDataSource()

public OkHttpDataSource.FactorysetCacheControl(CacheControl cacheControl)

Sets the that will be used.

public OkHttpDataSource.FactorysetContentTypePredicate(<any> contentTypePredicate)

Sets a content type .

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

public OkHttpDataSource.FactorysetTransferListener(TransferListener transferListener)

Sets the TransferListener that will be used.

public OkHttpDataSource.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(Call.Factory callFactory)

Creates an instance.

Parameters:

callFactory: A (typically an ) for use by the sources created by the factory.

Methods

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

public OkHttpDataSource.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 to be used.

Parameters:

userAgent: The user agent that will be used, or null to use the default user agent of the underlying .

Returns:

This factory.

public OkHttpDataSource.Factory setCacheControl(CacheControl cacheControl)

Sets the that will be used.

The default is null.

Parameters:

cacheControl: The cache control that will be used.

Returns:

This factory.

public OkHttpDataSource.Factory setContentTypePredicate(<any> contentTypePredicate)

Sets a content type . If a content type is rejected by the predicate then a is thrown from OkHttpDataSource.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 OkHttpDataSource.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 OkHttpDataSource createDataSource()