|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.fmj.ejmf.toolkit.media.AbstractClock
net.sf.fmj.ejmf.toolkit.media.AbstractController
net.sf.fmj.ejmf.toolkit.media.AbstractPlayer
public abstract class AbstractPlayer
The AbstractPlayer class provides a basic implementation of a javax.media.Player. The abstract "do" methods from AbstractController have been implemented here to provide support for management of multiple Controllers. Subclasses of this class should instead implement the following abstract "do" methods to transition their Controller:
The rules for implementation of these methods are identical to those for implementing a AbstractController:
Other abstact methods that should be implemented are:
From the book: Essential JMF, Gordon, Talley (ISBN 0130801046). Used with permission.
Field Summary |
---|
Fields inherited from interface javax.media.Controller |
---|
LATENCY_UNKNOWN, Prefetched, Prefetching, Realized, Realizing, Started, Unrealized |
Fields inherited from interface javax.media.Clock |
---|
RESET |
Fields inherited from interface javax.media.Duration |
---|
DURATION_UNBOUNDED, DURATION_UNKNOWN |
Constructor Summary | |
---|---|
AbstractPlayer()
Construct a AbstractPlayer. |
Method Summary | |
---|---|
void |
addController(Controller newController)
Adds a Controller to be controlled by this Player. |
void |
controllerUpdate(ControllerEvent e)
Used to monitor events posted by this Player's managed Controllers. |
void |
doClose()
Close the Player. |
boolean |
doDeallocate()
Deallocate player on current thread. |
abstract void |
doPlayerClose()
Close the Player. |
abstract boolean |
doPlayerDeallocate()
Implement to deallocate the Player. |
abstract boolean |
doPlayerPrefetch()
Implement to prefetch the Player. |
abstract boolean |
doPlayerRealize()
Implement to realize the Player. |
abstract void |
doPlayerSetMediaTime(Time t)
Override to provide implementation-specific functionality. |
abstract float |
doPlayerSetRate(float rate)
Override to provide implementation-specific functionality. |
abstract boolean |
doPlayerStop()
Implement to stop the Player. |
abstract boolean |
doPlayerSyncStart(Time t)
Implement to start the Player. |
boolean |
doPrefetch()
Prefetch player and all of its managed Controllers. |
boolean |
doRealize()
Realize player and all of its managed Controllers. |
void |
doSetMediaTime(Time t)
Sets the media time for this Player and all of its managed Controllers. |
float |
doSetRate(float rate)
Sets the rate for this Player and all of its managed Controllers. |
boolean |
doStop()
Stop player on current thread. |
boolean |
doSyncStart(Time t)
Start player and all of its managed Controllers at the given time. |
protected void |
endOfMedia()
Indicates to the framework that the end of media has been reached. |
protected java.util.Vector |
getControllers()
Gets the list of Controllers under control of this Player. |
java.awt.Component |
getControlPanelComponent()
Get the control panel Component for this Player. |
Time |
getDuration()
Gets the duration of this Player. |
GainControl |
getGainControl()
Get the Gain Control for this Player. |
abstract Time |
getPlayerDuration()
Returns the duration of the media played by this Player only. |
abstract Time |
getPlayerStartLatency()
Returns the start latency of the media played by this Player only. |
DataSource |
getSource()
Convenience method to get the DataSource for the Player. |
Time |
getStartLatency()
Gets the start latency of this Player. |
java.awt.Component |
getVisualComponent()
Get the visual Component for this Player. |
void |
removeController(Controller oldController)
Remove a Controller from the list of Controllers managed by this Player. |
protected void |
setControlPanelComponent(java.awt.Component c)
Set the control panal Component for this AbstractPlayer. |
protected void |
setGainControl(GainControl c)
Set the GainControl for this AbstractPlayer. |
void |
setMediaTime(Time t)
Sets the media time. |
float |
setRate(float rate)
Sets the rate. |
void |
setSource(DataSource source)
Called by javax.media.Manager. |
protected void |
setVisualComponent(java.awt.Component c)
Set the visual Component for this AbstractPlayer. |
void |
start()
Start the player on a new thread. |
protected void |
synchronousStart()
Start the AbstractPlayer ASAP. |
Methods inherited from class net.sf.fmj.ejmf.toolkit.media.AbstractClock |
---|
getMediaNanoseconds, getMediaStartTime, getRate, getStopTime, getSyncTime, getTimeBaseStartTime, mapToTimeBase |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.media.Controller |
---|
addControllerListener, close, deallocate, getControl, getControls, getState, getTargetState, prefetch, realize, removeControllerListener |
Methods inherited from interface javax.media.Clock |
---|
getMediaNanoseconds, getMediaTime, getRate, getStopTime, getSyncTime, getTimeBase, mapToTimeBase, setStopTime, setTimeBase, stop, syncStart |
Constructor Detail |
---|
public AbstractPlayer()
Method Detail |
---|
public abstract boolean doPlayerRealize()
This method should not be called directly. Instead, call realize().
public abstract boolean doPlayerPrefetch()
This method should not be called directly. Instead, call prefetch().
public abstract boolean doPlayerSyncStart(Time t)
This method should not be called directly. Instead, call start().
public abstract boolean doPlayerDeallocate()
This method should not be called directly. Instead, call deallocate().
public abstract boolean doPlayerStop()
This method should not be called directly. Instead, call stop().
public abstract void doPlayerClose()
This method should not be called directly. Instead, call close().
public abstract void doPlayerSetMediaTime(Time t)
This method should not be called directly. Instead, call setMediaTime().
t
- The media time to setpublic abstract float doPlayerSetRate(float rate)
This method should not be called directly. Instead, call setRate().
rate
- The requested rate to set
public abstract Time getPlayerStartLatency()
public abstract Time getPlayerDuration()
public final Time getDuration()
getDuration
in interface Duration
getDuration
in class AbstractController
public void setMediaTime(Time t)
setMediaTime
in interface Clock
setMediaTime
in class AbstractController
t
- The media time to set
NotRealizedError
- If the Controller is not Realized.public float setRate(float rate)
setRate
in interface Clock
setRate
in class AbstractController
rate
- The temporal scale factor (rate) to set.
NotRealizedError
- If the Controller is not Realized.public Time getStartLatency()
getStartLatency
in interface Controller
getStartLatency
in class AbstractController
public final void start()
Checks for Player state prerequisites and creates a StartThread to start the AbstractPlayer. If there is already a thread transitioning the AbstractPlayer forward, then the target state of the AbstractPlayer is set to Started and the method returns.
Asynchronous method -- Start synchronous transition on another thread and return ASAP.
start
in interface Player
public void addController(Controller newController) throws IncompatibleTimeBaseException
addController
in interface Player
newController
- The Controller to add
NotRealizedError
- If this Player or the new Controller are not
Realized.
ClockStartedError
- If this Player or the new Controller are in the
Started state.
IncompatibleTimeBaseException
- Thrown by newController.setTimeBase() if the
new Controller cannot use this player's
TimeBasepublic void removeController(Controller oldController)
removeController
in interface Player
oldController
- The Controller to removeprotected java.util.Vector getControllers()
protected void setGainControl(GainControl c)
c
- The GainControl allowing control of the volume
of this AbstractPlayer's media.public GainControl getGainControl()
getGainControl
in interface Player
protected void setVisualComponent(java.awt.Component c)
c
- A java.awt.Component on which the media is
rendered.public java.awt.Component getVisualComponent()
getVisualComponent
in interface Player
protected void setControlPanelComponent(java.awt.Component c)
c
- A java.awt.Component providing control over
this AbstractPlayer's media.public java.awt.Component getControlPanelComponent()
getControlPanelComponent
in interface Player
public void setSource(DataSource source) throws IncompatibleSourceException
setSource
in interface MediaHandler
source
- The DataSource to test
IncompatibleSourceException
- Thrown if the DataSource has already been set
on this MediaHandler, or if the DataSource is
not a PullDataSourcepublic DataSource getSource()
public final void controllerUpdate(ControllerEvent e)
This method is final because the controller-management functionality of the AbstractPlayer will not work if it is overridden.
controllerUpdate
in interface ControllerListener
e
- The ControllerEvent posted by one of the
managed Controllers.public final boolean doRealize()
This method should not be called directly. Instead, call realize().
doRealize
in class AbstractController
public final boolean doPrefetch()
This method should not be called directly. Instead, call prefetch().
doPrefetch
in class AbstractController
public final boolean doSyncStart(Time t)
This method should not be called directly. Instead, call syncStart().
doSyncStart
in class AbstractController
public final boolean doDeallocate()
This method should not be called directly. Instead, call deallocate().
doDeallocate
in class AbstractController
public final boolean doStop()
This method should not be called directly. Instead, call stop().
doStop
in class AbstractController
public final void doClose()
This method should not be called directly. Instead, call close().
doClose
in class AbstractController
public final void doSetMediaTime(Time t)
This method should not be called directly. Instead, call setMediaTime().
doSetMediaTime
in class AbstractController
t
- The media time to set.public final float doSetRate(float rate)
This method should not be called directly. Instead, call setRate().
doSetRate
in class AbstractController
rate
- The rate to set.
protected void endOfMedia() throws ClockStoppedException
endOfMedia
in class AbstractController
ClockStoppedException
- If the AbstractController is not in the Started
state.protected void synchronousStart()
Synchronous method -- return when transition complete
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |