Class DefaultDataSource

  • All Implemented Interfaces:
    DataReader, DataSource

    @Deprecated
    public final class DefaultDataSource
    extends Object
    implements DataSource
    Deprecated.
    com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    A DataSource that supports multiple URI schemes. The supported schemes are:
    • file: For fetching data from a local file (e.g. file:///path/to/media/media.mp4, or just /path/to/media/media.mp4 because the implementation assumes that a URI without a scheme is a local file URI).
    • asset: For fetching data from an asset in the application's APK (e.g. asset:///media.mp4).
    • rawresource: For fetching data from a raw resource in the application's APK (e.g. rawresource:///resourceId, where rawResourceId is the integer identifier of the raw resource).
    • android.resource: For fetching data in the application's APK (e.g. android.resource:///resourceId or android.resource://resourceType/resourceName). See RawResourceDataSource for more information about the URI form.
    • content: For fetching data from a content URI (e.g. content://authority/path/123).
    • rtmp: For fetching data over RTMP. Only supported if the project using ExoPlayer has an explicit dependency on ExoPlayer's RTMP extension.
    • data: For parsing data inlined in the URI as defined in RFC 2397.
    • udp: For fetching data over UDP (e.g. udp://something.com/media).
    • http(s): For fetching data over HTTP and HTTPS (e.g. https://www.something.com/media.mp4), if constructed using DefaultDataSource(Context, String, boolean), or any other schemes supported by a base data source if constructed using DefaultDataSource(Context, DataSource).
    • Constructor Detail

      • DefaultDataSource

        public DefaultDataSource​(Context context,
                                 boolean allowCrossProtocolRedirects)
        Deprecated.
        Constructs a new instance, optionally configured to follow cross-protocol redirects.
        Parameters:
        context - A context.
        allowCrossProtocolRedirects - Whether to allow cross-protocol redirects.
      • DefaultDataSource

        public DefaultDataSource​(Context context,
                                 @Nullable
                                 String userAgent,
                                 boolean allowCrossProtocolRedirects)
        Deprecated.
        Constructs a new instance, optionally configured to follow cross-protocol redirects.
        Parameters:
        context - A context.
        userAgent - The user agent that will be used when requesting remote data, or null to use the default user agent of the underlying platform.
        allowCrossProtocolRedirects - Whether cross-protocol redirects (i.e. redirects from HTTP to HTTPS and vice versa) are enabled when fetching remote data.
      • DefaultDataSource

        public DefaultDataSource​(Context context,
                                 @Nullable
                                 String userAgent,
                                 int connectTimeoutMillis,
                                 int readTimeoutMillis,
                                 boolean allowCrossProtocolRedirects)
        Deprecated.
        Constructs a new instance, optionally configured to follow cross-protocol redirects.
        Parameters:
        context - A context.
        userAgent - The user agent that will be used when requesting remote data, or null to use the default user agent of the underlying platform.
        connectTimeoutMillis - The connection timeout that should be used when requesting remote data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
        readTimeoutMillis - The read timeout that should be used when requesting remote data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
        allowCrossProtocolRedirects - Whether cross-protocol redirects (i.e. redirects from HTTP to HTTPS and vice versa) are enabled when fetching remote data.
      • DefaultDataSource

        public DefaultDataSource​(Context context,
                                 DataSource baseDataSource)
        Deprecated.
        Constructs a new instance that delegates to a provided DataSource for URI schemes other than file, asset and content.
        Parameters:
        context - A context.
        baseDataSource - A DataSource to use for URI schemes other than file, asset and content. This DataSource should normally support at least http(s).