public abstract class MediaDataSource extends Object implements Closeable
Methods of this interface may be called on multiple different threads. There will be a thread synchronization point between each call to ensure that modifications to the state of your MediaDataSource are visible to future calls. This means you don't need to do your own synchronization unless you're modifying the MediaDataSource from another thread while it's being used by the framework.
Constructor and Description |
---|
MediaDataSource() |
Modifier and Type | Method and Description |
---|---|
abstract long |
getSize()
Called to get the size of the data source.
|
abstract int |
readAt(long position,
byte[] buffer,
int offset,
int size)
Called to request data from the given position.
|
public abstract int readAt(long position, byte[] buffer, int offset, int size) throws IOException
size
bytes into
buffer
, and return the number of bytes written.
Return 0
if size is zero (thus no bytes are read).
Return -1
to indicate that end of stream is reached.position
- the position in the data source to read from.buffer
- the buffer to read the data into.offset
- the offset within buffer to read the data into.size
- the number of bytes to read.IOException
- on fatal errors.public abstract long getSize() throws IOException
IOException
- on fatal errors