Interface DataSourceFactory

All Superinterfaces:
com.google.android.exoplayer2.upstream.DataSource.Factory
All Known Implementing Classes:
DefaultDataSourceFactory, ModifierDataSourceFactory

public interface DataSourceFactory extends com.google.android.exoplayer2.upstream.DataSource.Factory
Implementations of this interface are used to create DataSources to fetch remote data.

The implementation should allow to customize both header and query parameters for generated data sources.

Please use the PlayerSDK.HTTP_DATASOURCE_BUILDER as the source for any HttpDataSource instances.

Since:
3.0.0
  • Method Details

    • addHeaderParameter

      void addHeaderParameter(@NonNull String key, @NonNull String value)
      Adds a header parameter that will be added to each HTTP connection header that is generated with a DataSource created by this factory.

      Note that you will need to call this before a call to DataSource.Factory.createDataSource() in order to successfully add the parameter.

      Parameters:
      key - the key
      value - the value or null to remove any previously added endtry with the given key
    • clearHeaderParameters

      void clearHeaderParameters()
      Removes all header parameters added previously with addHeaderParameter(String, String).
    • addQueryParameter

      void addQueryParameter(@NonNull String key, @NonNull String value)
      Adds a query parameter that will be appended to each HTTP URL.

      Note that you will need to call this before a call to DataSource.Factory.createDataSource() in order to successfully add the parameter.

      Parameters:
      key - the key
      value - the value or null to remove any previously added entry with the given key
    • clearQueryParameters

      void clearQueryParameters()
      Removes all query parameters added previously with addQueryParameter(String, String)
    • getHeaderParameter

      @NonNull Map<String,String> getHeaderParameter()
      Returns:
      A non-null map of all registered header parameter
    • getQueryParameter

      @NonNull Map<String,String> getQueryParameter()
      Returns:
      A non-null map of all registered query parameter
    • createDataSource

      com.google.android.exoplayer2.upstream.DataSource createDataSource(int requestType)
      Creates a data source for the given request type
      Parameters:
      requestType - The request type
      Returns:
      dataSource the data source