com.google.android.exoplayer2.upstream.DefaultHttpDataSource Java Examples

The following examples show how to use com.google.android.exoplayer2.upstream.DefaultHttpDataSource. 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: ExtendedDefaultDataSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param listener An optional listener.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @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 when fetching remote data.
 * @deprecated Use {@link #DefaultDataSource(Context, String, int, int, boolean)} and {@link
 *     #addTransferListener(TransferListener)}.
 */
@Deprecated
@SuppressWarnings("deprecation")
public ExtendedDefaultDataSource(
        Context context,
        @Nullable TransferListener listener,
        String userAgent,
        int connectTimeoutMillis,
        int readTimeoutMillis,
        boolean allowCrossProtocolRedirects) {
    this(
            context,
            listener,
            new DefaultHttpDataSource(
                    userAgent,
                    /* contentTypePredicate= */ null,
                    listener,
                    connectTimeoutMillis,
                    readTimeoutMillis,
                    allowCrossProtocolRedirects,
                    /* defaultRequestProperties= */ null));
}
 
Example #2
Source File: ExtendedDefaultDataSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @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 when fetching remote data.
 */
public ExtendedDefaultDataSource(
        Context context,
        String userAgent,
        int connectTimeoutMillis,
        int readTimeoutMillis,
        boolean allowCrossProtocolRedirects) {
    this(
            context,
            new DefaultHttpDataSource(
                    userAgent,
                    /* contentTypePredicate= */ null,
                    connectTimeoutMillis,
                    readTimeoutMillis,
                    allowCrossProtocolRedirects,
                    /* defaultRequestProperties= */ null));
}
 
Example #3
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 #4
Source File: ExtendedDefaultDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param listener An optional listener.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @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 when fetching remote data.
 * @deprecated Use {@link #DefaultDataSource(Context, String, int, int, boolean)} and {@link
 *     #addTransferListener(TransferListener)}.
 */
@Deprecated
@SuppressWarnings("deprecation")
public ExtendedDefaultDataSource(
        Context context,
        @Nullable TransferListener listener,
        String userAgent,
        int connectTimeoutMillis,
        int readTimeoutMillis,
        boolean allowCrossProtocolRedirects) {
    this(
            context,
            listener,
            new DefaultHttpDataSource(
                    userAgent,
                    /* contentTypePredicate= */ null,
                    listener,
                    connectTimeoutMillis,
                    readTimeoutMillis,
                    allowCrossProtocolRedirects,
                    /* defaultRequestProperties= */ null));
}
 
Example #5
Source File: ExtendedDefaultDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @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 when fetching remote data.
 */
public ExtendedDefaultDataSource(
        Context context,
        String userAgent,
        int connectTimeoutMillis,
        int readTimeoutMillis,
        boolean allowCrossProtocolRedirects) {
    this(
            context,
            new DefaultHttpDataSource(
                    userAgent,
                    /* contentTypePredicate= */ null,
                    connectTimeoutMillis,
                    readTimeoutMillis,
                    allowCrossProtocolRedirects,
                    /* defaultRequestProperties= */ null));
}
 
Example #6
Source File: ArviHttpDataSourceFactory.java    From ARVI with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an ArviHttpDataSourceFactory. Sets {@link DefaultHttpDataSource#DEFAULT_CONNECT_TIMEOUT_MILLIS} as the connection timeout,
 * {@link DefaultHttpDataSource#DEFAULT_READ_TIMEOUT_MILLIS} as the read timeout and disables cross-protocol redirects.
 *
 * @param userAgent The User-Agent string that should be used.
 * @param listener An optional listener.
 * @see #DefaultHttpDataSourceFactory(String, TransferListener, int, int, boolean)
 */
public ArviHttpDataSourceFactory(String userAgent, TransferListener listener) {
    this(
        userAgent,
        listener,
        null,
        DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
        DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
        false
    );
}
 
Example #7
Source File: ExtendedDefaultDataSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled when fetching remote data.
 */
public ExtendedDefaultDataSource(Context context, String userAgent, boolean allowCrossProtocolRedirects) {
    this(
            context,
            userAgent,
            DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
            DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
            allowCrossProtocolRedirects);
}
 
Example #8
Source File: MediaSourceFactory.java    From no-player with Apache License 2.0 5 votes vote down vote up
private DefaultDataSourceFactory createDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) {
    if (dataSourceFactory.isPresent()) {
        return new DefaultDataSourceFactory(context, bandwidthMeter, dataSourceFactory.get());
    } else {
        DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory(
                userAgent,
                bandwidthMeter,
                DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
                allowCrossProtocolRedirects
        );

        return new DefaultDataSourceFactory(context, bandwidthMeter, httpDataSourceFactory);
    }
}
 
Example #9
Source File: VideoDialogFragment.java    From TDTChannels-APP with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_video_dialog, container, false);

    channelVideoView = rootView.findViewById(R.id.channel_video_detail_exoplayer);

    if (getArguments() != null) {
        String channelUrl = getArguments().getString(CHANNEL_KEY);
        if (getActivity() != null && getContext() != null && channelUrl != null) {
            player = new SimpleExoPlayer.Builder(getContext()).build();

            DefaultHttpDataSourceFactory httpDataSourceFactory = new DefaultHttpDataSourceFactory(
                    Util.getUserAgent(getContext(), "laquay.com.open.canalestdt"),
                    DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                    DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
                    true
            );

            dataSourceFactory = new DefaultDataSourceFactory(getContext(), httpDataSourceFactory);

            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            loadVideo(channelUrl);
        }
    }
    return rootView;
}
 
Example #10
Source File: ExtendedDefaultDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled when fetching remote data.
 */
public ExtendedDefaultDataSource(Context context, String userAgent, boolean allowCrossProtocolRedirects) {
    this(
            context,
            userAgent,
            DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
            DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
            allowCrossProtocolRedirects);
}
 
Example #11
Source File: VideoExoPlayer.java    From TigerVideo with Apache License 2.0 4 votes vote down vote up
private HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter) {

        return new DefaultHttpDataSourceFactory(Util.getUserAgent(mContext, TAG), bandwidthMeter, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true);
    }
 
Example #12
Source File: ExtendedDefaultDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param listener An optional listener.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled when fetching remote data.
 * @deprecated Use {@link #DefaultDataSource(Context, String, boolean)} and {@link
 *     #addTransferListener(TransferListener)}.
 */
@Deprecated
@SuppressWarnings("deprecation")
public ExtendedDefaultDataSource(
        Context context,
        @Nullable TransferListener listener,
        String userAgent,
        boolean allowCrossProtocolRedirects) {
    this(context, listener, userAgent, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
            DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects);
}
 
Example #13
Source File: ExtendedDefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context                     A context.
 * @param listener                    An optional listener.
 * @param userAgent                   The User-Agent string that should be used when requesting remote data.
 * @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 when fetching remote data.
 */
public ExtendedDefaultDataSource(Context context, TransferListener listener,
                                 String userAgent, int connectTimeoutMillis, int readTimeoutMillis,
                                 boolean allowCrossProtocolRedirects) {
    this(context, listener,
            new DefaultHttpDataSource(userAgent, null, listener, connectTimeoutMillis,
                    readTimeoutMillis, allowCrossProtocolRedirects, null));
}
 
Example #14
Source File: ExtendedDefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context                     A context.
 * @param listener                    An optional listener.
 * @param userAgent                   The User-Agent string that should be used when requesting remote data.
 * @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 when fetching remote data.
 */
public ExtendedDefaultDataSource(Context context, TransferListener listener,
                                 String userAgent, int connectTimeoutMillis, int readTimeoutMillis,
                                 boolean allowCrossProtocolRedirects) {
    this(context, listener,
            new DefaultHttpDataSource(userAgent, null, listener, connectTimeoutMillis,
                    readTimeoutMillis, allowCrossProtocolRedirects, null));
}
 
Example #15
Source File: ExtendedDefaultDataSource.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context A context.
 * @param listener An optional listener.
 * @param userAgent The User-Agent to use when requesting remote data.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled when fetching remote data.
 * @deprecated Use {@link #DefaultDataSource(Context, String, boolean)} and {@link
 *     #addTransferListener(TransferListener)}.
 */
@Deprecated
@SuppressWarnings("deprecation")
public ExtendedDefaultDataSource(
        Context context,
        @Nullable TransferListener listener,
        String userAgent,
        boolean allowCrossProtocolRedirects) {
    this(context, listener, userAgent, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
            DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects);
}
 
Example #16
Source File: ExtendedDefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context                     A context.
 * @param listener                    An optional listener.
 * @param userAgent                   The User-Agent string that should be used when requesting remote data.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *                                    to HTTPS and vice versa) are enabled when fetching remote data.
 */
public ExtendedDefaultDataSource(Context context, TransferListener listener,
                                 String userAgent, boolean allowCrossProtocolRedirects) {
    this(context, listener, userAgent, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
            DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects);
}
 
Example #17
Source File: ExtendedDefaultDataSource.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new instance, optionally configured to follow cross-protocol redirects.
 *
 * @param context                     A context.
 * @param listener                    An optional listener.
 * @param userAgent                   The User-Agent string that should be used when requesting remote data.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *                                    to HTTPS and vice versa) are enabled when fetching remote data.
 */
public ExtendedDefaultDataSource(Context context, TransferListener listener,
                                 String userAgent, boolean allowCrossProtocolRedirects) {
    this(context, listener, userAgent, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
            DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, allowCrossProtocolRedirects);
}