CallbackDataSource2
public
abstract
class
CallbackDataSource2
extends Object
implements
Closeable
java.lang.Object
|
↳ |
androidx.media2.CallbackDataSource2
|
For supplying media data, implement this if your app has special requirements for the way media
data is obtained.
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 CallbackDataSource2 are visible to future calls. This means
you don't need to do your own synchronization unless you're modifying the
CallbackDataSource2 from another thread while it's being used by the media library.
Summary
Public methods |
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.
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
From interface
java.io.Closeable
|
From interface
java.lang.AutoCloseable
|
Public constructors
CallbackDataSource2
public CallbackDataSource2 ()
Public methods
getSize
public abstract long getSize ()
Called to get the size of the data source.
Returns |
long |
the size of data source in bytes, or -1 if the size is unknown.
|
Throws |
IOException |
on fatal errors |
readAt
public abstract int readAt (long position,
byte[] buffer,
int offset,
int size)
Called to request data from the given position.
Implementations should should write up to 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.
Parameters |
position |
long : the position in the data source to read from. |
buffer |
byte : the buffer to read the data into. |
offset |
int : the offset within buffer to read the data into. |
size |
int : the number of bytes to read. |
Returns |
int |
the number of bytes read, or -1 if there was an error.
|
Throws |
IOException |
on fatal errors. |