Class MultiDataSource

  • All Implemented Interfaces:
    com.google.android.exoplayer2.upstream.DataReader, com.google.android.exoplayer2.upstream.DataSource

    public class MultiDataSource
    extends java.lang.Object
    implements com.google.android.exoplayer2.upstream.DataSource

    Multi data source supports fetching assets from multiple URI schemes. If the data source is an HTTP/HTTPS source, then it will check the offline store to check if the asset has been downloaded already and automatically convert to DataSpec to point to local copy of the asset.

    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).
    • 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.
    • http(s): For fetching data over HTTP and HTTPS (e.g. https://www.something.com/media.mp4).

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected com.google.android.exoplayer2.upstream.DataSource delegate  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addTransferListener​(com.google.android.exoplayer2.upstream.TransferListener transferListener)  
      void close()  
      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getResponseHeaders()  
      android.net.Uri getUri()  
      long open​(com.google.android.exoplayer2.upstream.DataSpec dataSpec)  
      int read​(byte[] buffer, int offset, int readLength)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • delegate

        @Nullable
        protected com.google.android.exoplayer2.upstream.DataSource delegate
    • Method Detail

      • addTransferListener

        public void addTransferListener​(com.google.android.exoplayer2.upstream.TransferListener transferListener)
        Specified by:
        addTransferListener in interface com.google.android.exoplayer2.upstream.DataSource
      • open

        public long open​(com.google.android.exoplayer2.upstream.DataSpec dataSpec)
                  throws java.io.IOException
        Specified by:
        open in interface com.google.android.exoplayer2.upstream.DataSource
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] buffer,
                        int offset,
                        int readLength)
                 throws java.io.IOException
        Specified by:
        read in interface com.google.android.exoplayer2.upstream.DataReader
        Throws:
        java.io.IOException
      • getUri

        public android.net.Uri getUri()
        Specified by:
        getUri in interface com.google.android.exoplayer2.upstream.DataSource
      • getResponseHeaders

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getResponseHeaders()
        Specified by:
        getResponseHeaders in interface com.google.android.exoplayer2.upstream.DataSource
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface com.google.android.exoplayer2.upstream.DataSource
        Throws:
        java.io.IOException