public abstract class DataSource extends Object implements Controls, Duration
DataSource is an abstraction for media protocol-handlers.
DataSource manages the life-cycle of the media source
by providing a simple connection protocol.
DataSource might support an operation
that is not part of the DataSource
class definition. For example a source could support
positioning its media to a particular time.
Some operations are dependent on the data stream that the
source is managing, and support cannot be determined
until after the source has been connected.
To obtain all of the objects that provide control
over a DataSource, use getControls
which returns an array of Object
To determine if a particular kind of control
is available and obtain the object that implements
it, use getControl which takes
the name of the Class or Interface that of the
desired control.
Manager,
DefaultPlayerFactory,
Positionable,
RateConfigureableDURATION_UNBOUNDED, DURATION_UNKNOWN| Constructor and Description |
|---|
DataSource()
A no-argument constructor required by pre 1.1 implementations
so that this class can be instantiated by
calling
Class.newInstance. |
DataSource(MediaLocator source)
Construct a
DataSource from a MediaLocator. |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
connect()
Open a connection to the source described by
the
MediaLocator. |
abstract void |
disconnect()
Close the connection to the source described by the locator.
|
abstract String |
getContentType()
Get a string that describes the content-type of the media
that the source is providing.
|
MediaLocator |
getLocator()
Get the
MediaLocator that describes this source. |
protected void |
initCheck()
Check to see if this connection has been
initialized with a
MediaLocator. |
void |
setLocator(MediaLocator source)
Set the connection
source for this DataSource. |
abstract void |
start()
Initiate data-transfer.
|
abstract void |
stop()
Stop the data-transfer.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetControl, getControlsgetDurationpublic DataSource()
Class.newInstance.public DataSource(MediaLocator source)
DataSource from a MediaLocator.
This method should be overloaded by subclasses;
the default implementation just keeps track of
the MediaLocator.source - The MediaLocator that describes
the DataSource.public void setLocator(MediaLocator source)
source for this DataSource.
This method should only be called once; an error is thrown if
the locator has already been set.source - The MediaLocator that describes the
media source.public MediaLocator getLocator()
MediaLocator that describes this source.
Returns null if the locator hasn't been set.
(Very unlikely.)MediaLocator for this source.protected void initCheck()
MediaLocator.
If the connection hasn't been initialized,
initCheck throws an UninitializedError.
Most methods should call initCheck on entry.public abstract String getContentType()
It is an error to call getContentType if the source is
not connected.
public abstract void connect()
throws IOException
MediaLocator.
The connect method initiates communication with the source.
IOException - Thrown if there are IO problems
when connect is called.public abstract void disconnect()
The disconnect method frees resources used to maintain a
connection to the source.
If no resources are in use, disconnect is ignored.
If stop hasn't already been called,
calling disconnect implies a stop.
public abstract void start()
throws IOException
start method must be
called before data is available.
(You must call connect before calling start.)IOException - Thrown if there are IO problems with the source
when start is called.public abstract void stop()
throws IOException
stop does nothing.IOExceptionCopyright © 2012 code4tv.com. All Rights Reserved.