OkHttpDataSourceFactory


@UnstableApi
public final class OkHttpDataSourceFactory extends HttpDataSource.BaseFactory


Summary

Public constructors

Creates an instance.

OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent
)

Creates an instance.

OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent,
    @Nullable CacheControl cacheControl
)

Creates an instance.

OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent,
    @Nullable TransferListener listener
)

Creates an instance.

OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent,
    @Nullable TransferListener listener,
    @Nullable CacheControl cacheControl
)

Creates an instance.

Protected methods

OkHttpDataSource

Called by createDataSource to create a HttpDataSource instance.

Inherited methods

From androidx.media3.datasource.DataSource.Factory
abstract DataSource

Creates a DataSource instance.

From androidx.media3.datasource.HttpDataSource.BaseFactory
final HttpDataSource

Creates a DataSource instance.

final HttpDataSource.Factory
@CanIgnoreReturnValue
setDefaultRequestProperties(
    Map<StringString> defaultRequestProperties
)

Sets the default request headers for HttpDataSource instances created by the factory.

Public constructors

OkHttpDataSourceFactory

public OkHttpDataSourceFactory(Call.Factory callFactory)

Creates an instance.

Parameters
Call.Factory callFactory

A Call.Factory (typically an okhttp3.OkHttpClient) for use by the sources created by the factory.

OkHttpDataSourceFactory

public OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent
)

Creates an instance.

Parameters
Call.Factory callFactory

A Call.Factory (typically an okhttp3.OkHttpClient) for use by the sources created by the factory.

@Nullable String userAgent

An optional User-Agent string.

OkHttpDataSourceFactory

public OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent,
    @Nullable CacheControl cacheControl
)

Creates an instance.

Parameters
Call.Factory callFactory

A Call.Factory (typically an okhttp3.OkHttpClient) for use by the sources created by the factory.

@Nullable String userAgent

An optional User-Agent string.

@Nullable CacheControl cacheControl

An optional CacheControl for setting the Cache-Control header.

OkHttpDataSourceFactory

public OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent,
    @Nullable TransferListener listener
)

Creates an instance.

Parameters
Call.Factory callFactory

A Call.Factory (typically an okhttp3.OkHttpClient) for use by the sources created by the factory.

@Nullable String userAgent

An optional User-Agent string.

@Nullable TransferListener listener

An optional listener.

OkHttpDataSourceFactory

public OkHttpDataSourceFactory(
    Call.Factory callFactory,
    @Nullable String userAgent,
    @Nullable TransferListener listener,
    @Nullable CacheControl cacheControl
)

Creates an instance.

Parameters
Call.Factory callFactory

A Call.Factory (typically an okhttp3.OkHttpClient) for use by the sources created by the factory.

@Nullable String userAgent

An optional User-Agent string.

@Nullable TransferListener listener

An optional listener.

@Nullable CacheControl cacheControl

An optional CacheControl for setting the Cache-Control header.

Protected methods

createDataSourceInternal

protected OkHttpDataSource createDataSourceInternal(
    HttpDataSource.RequestProperties defaultRequestProperties
)

Called by createDataSource to create a HttpDataSource instance.

Parameters
HttpDataSource.RequestProperties defaultRequestProperties

The default RequestProperties to be used by the HttpDataSource instance.

Returns
OkHttpDataSource

A HttpDataSource instance.