Package com.castlabs.android.downloader
Class ZipDataSource
java.lang.Object
com.castlabs.android.downloader.ZipDataSource
- All Implemented Interfaces:
com.google.android.exoplayer2.upstream.DataSource
public class ZipDataSource
extends Object
implements com.google.android.exoplayer2.upstream.DataSource
Implementation of a DataSource that can read data from a zip file. The URI scheme for this
should be zip. We expect to get a URI where the path consistes of the
path to the zip and the path to the zip entry. For example
zip:/path/to/container.zip/path/to/entry.txt
.- Since:
- 3.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Thrown when IOException is encountered during local file read operation.Nested classes/interfaces inherited from interface com.google.android.exoplayer2.upstream.DataSource
com.google.android.exoplayer2.upstream.DataSource.Factory
-
Constructor Summary
ConstructorDescriptionConstructs a newDataSource
that retrieves data from a file.ZipDataSource
(com.google.android.exoplayer2.upstream.TransferListener listener) Constructs a newDataSource
that retrieves data from a file. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTransferListener
(com.google.android.exoplayer2.upstream.TransferListener listener) void
close()
int
getUri()
long
open
(com.google.android.exoplayer2.upstream.DataSpec dataSpec) int
read
(byte[] buffer, int offset, int readLength)
-
Constructor Details
-
ZipDataSource
public ZipDataSource()Constructs a newDataSource
that retrieves data from a file. -
ZipDataSource
public ZipDataSource(com.google.android.exoplayer2.upstream.TransferListener listener) Constructs a newDataSource
that retrieves data from a file.- Parameters:
listener
- An optional listener. Specifynull
for no listener.
-
-
Method Details
-
getResponseCode
public int getResponseCode()- Specified by:
getResponseCode
in interfacecom.google.android.exoplayer2.upstream.DataSource
-
getResponseHeaders
- Specified by:
getResponseHeaders
in interfacecom.google.android.exoplayer2.upstream.DataSource
-
addTransferListener
public void addTransferListener(com.google.android.exoplayer2.upstream.TransferListener listener) - Specified by:
addTransferListener
in interfacecom.google.android.exoplayer2.upstream.DataSource
-
open
public long open(com.google.android.exoplayer2.upstream.DataSpec dataSpec) throws ZipDataSource.ZipDataSourceException - Specified by:
open
in interfacecom.google.android.exoplayer2.upstream.DataSource
- Throws:
ZipDataSource.ZipDataSourceException
-
read
public int read(byte[] buffer, int offset, int readLength) throws ZipDataSource.ZipDataSourceException - Specified by:
read
in interfacecom.google.android.exoplayer2.upstream.DataSource
- Throws:
ZipDataSource.ZipDataSourceException
-
getUri
- Specified by:
getUri
in interfacecom.google.android.exoplayer2.upstream.DataSource
-
close
- Specified by:
close
in interfacecom.google.android.exoplayer2.upstream.DataSource
- Throws:
ZipDataSource.ZipDataSourceException
-