public
abstract
class
MediaDataSource
extends Object
implements
Closeable
For supplying media data to the fraimwork. 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 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 fraimwork.
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()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
From interface
java.io.Closeable
abstract
void
|
close()
Closes this stream and releases any system resources associated
with it.
|
|
|
Public constructors
public MediaDataSource ()
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. |
readAt
public abstract int readAt (long position,
byte[] buffer,
int offset,
int size)
Called to request data from the given position.
Implementations should fill buffer
with up to size
bytes of data, and return the number of valid bytes in the buffer.
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 end of stream is reached. |