Java Code Examples for com.google.android.exoplayer2.upstream.HttpDataSource#RequestProperties

The following examples show how to use com.google.android.exoplayer2.upstream.HttpDataSource#RequestProperties . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArviHttpDataSourceFactory.java    From ARVI with Apache License 2.0 6 votes vote down vote up
@Override
protected DefaultHttpDataSource createDataSourceInternal(HttpDataSource.RequestProperties defaultRequestProperties) {
    final HttpDataSource.RequestProperties finalRequestProperties = new HttpDataSource.RequestProperties();
    finalRequestProperties.set(this.requestProperties.getSnapshot());
    finalRequestProperties.set(defaultRequestProperties.getSnapshot());

    final DefaultHttpDataSource dataSource = new ArviHttpDataSource(
        this.userAgent,
        null,
        this.connectTimeoutMillis,
        this.readTimeoutMillis,
        this.allowCrossProtocolRedirects,
        finalRequestProperties
    ).setRequestAuthorizer(this.requestAuthorizer);

    if(this.listener != null) {
        dataSource.addTransferListener(this.listener);
    }

    return dataSource;
}
 
Example 2
Source File: IcyHttpDataSourceFactoryTest.java    From android-exoplayer2-ext-icy with Apache License 2.0 6 votes vote down vote up
@Test
public void createDataSourceViaFactoryFromFactoryBuilder() {
    // Arrange
    OkHttpClient client = new OkHttpClient.Builder().build();
    IcyHttpDataSourceFactory factory = new IcyHttpDataSourceFactory.Builder(client)
            .setUserAgent(Constants.TEST_USER_AGENT)
            .setIcyHeadersListener(TEST_ICY_HEADERS_LISTENER)
            .setIcyMetadataChangeListener(TEST_ICY_METADATA_LISTENER)
            .build();
    HttpDataSource.RequestProperties requestProperties = new HttpDataSource.RequestProperties();

    // Act
    IcyHttpDataSource source = factory.createDataSourceInternal(requestProperties);

    // Assert
    assertNotNull(source);
}
 
Example 3
Source File: ArviHttpDataSourceFactory.java    From ARVI with Apache License 2.0 5 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param listener An optional listener.
 * @param connectTimeoutMillis The connection timeout that should be used when requesting remote
 *        data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param readTimeoutMillis The read timeout that should be used when requesting remote data, in
 *        milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *        to HTTPS and vice versa) are enabled.
 */
public ArviHttpDataSourceFactory(String userAgent,
                                 TransferListener listener,
                                 RequestAuthorizer requestAuthorizer,
                                 int connectTimeoutMillis,
                                 int readTimeoutMillis,
                                 boolean allowCrossProtocolRedirects) {
    this.userAgent = userAgent;
    this.listener = listener;
    this.requestAuthorizer = requestAuthorizer;
    this.connectTimeoutMillis = connectTimeoutMillis;
    this.readTimeoutMillis = readTimeoutMillis;
    this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
    this.requestProperties = new HttpDataSource.RequestProperties();
}
 
Example 4
Source File: IcyHttpDataSourceFactory.java    From android-exoplayer2-ext-icy with Apache License 2.0 5 votes vote down vote up
@Override
protected IcyHttpDataSource createDataSourceInternal(@NonNull HttpDataSource.RequestProperties defaultRequestProperties) {
    return new IcyHttpDataSource.Builder(callFactory)
            .setUserAgent(userAgent)
            .setContentTypePredicate(contentTypePredicate)
            .setCacheControl(cacheControl)
            .setDefaultRequestProperties(defaultRequestProperties)
            .setIcyHeadersListener(icyHeadersListener)
            .setIcyMetadataListener(icyMetadataListener)
            .build();
}
 
Example 5
Source File: GSYExoHttpDataSourceFactory.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
@Override
protected GSYDefaultHttpDataSource createDataSourceInternal(
        HttpDataSource.RequestProperties defaultRequestProperties) {
    GSYDefaultHttpDataSource dataSource =
            new GSYDefaultHttpDataSource(
                    userAgent,
                    connectTimeoutMillis,
                    readTimeoutMillis,
                    allowCrossProtocolRedirects,
                    defaultRequestProperties);
    if (listener != null) {
        dataSource.addTransferListener(listener);
    }
    return dataSource;
}