Package com.castlabs.android.network
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.FactoryImplementations of this interface are used to createDataSources to fetch remote data. The implementation should allow to customize both header and query parameters for generated data sources. Please use thePlayerSDK.HTTP_DATASOURCE_BUILDERas the source for anyHttpDataSourceinstances.- Since:
- 3.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddHeaderParameter(String key, String value)Adds a header parameter that will be added to each HTTP connection header that is generated with aDataSourcecreated by this factory.voidaddQueryParameter(String key, String value)Adds a query parameter that will be appended to each HTTP URL.voidclearHeaderParameters()Removes all header parameters added previously withaddHeaderParameter(String, String).voidclearQueryParameters()Removes all query parameters added previously withaddQueryParameter(String, String)com.google.android.exoplayer2.upstream.DataSourcecreateDataSource(int requestType)Creates a data source for the given request typeMap<String,String>getHeaderParameter()Map<String,String>getQueryParameter()
-
-
-
Method Detail
-
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 aDataSourcecreated by this factory. Note that you will need to call this before a call toDataSource.Factory.createDataSource()in order to successfully add the parameter.- Parameters:
key- the keyvalue- the value or null to remove any previously added endtry with the given key
-
clearHeaderParameters
void clearHeaderParameters()
Removes all header parameters added previously withaddHeaderParameter(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 toDataSource.Factory.createDataSource()in order to successfully add the parameter.- Parameters:
key- the keyvalue- the value or null to remove any previously added entry with the given key
-
clearQueryParameters
void clearQueryParameters()
Removes all query parameters added previously withaddQueryParameter(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
-
-