public abstract class MediaPlayer extends MediaController implements Player, GainChangeListener
| Modifier and Type | Field and Description |
|---|---|
protected Control[] |
controls |
static ColorModel |
defaultColorModel |
protected GainControl |
gainControl |
protected DataSource |
source |
protected static TimeBase |
systemTimeBase |
static String |
VERSION |
parent, stateLATENCY_UNKNOWN, Prefetched, Prefetching, Realized, Realizing, Started, UnrealizedDURATION_UNBOUNDED, DURATION_UNKNOWN| Constructor and Description |
|---|
MediaPlayer()
Constructs a MediaPlayer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
abortPrefetch()
Called when the prefetch() is aborted, i.e.
|
protected void |
abortRealize()
Called when the realize() is aborted, i.e.
|
void |
addController(Controller newController)
Assume control of another Controller.
|
void |
addControls(Control[] newControls)
Add more controls to the player
|
protected void |
addNode(Controller node)
Add a MediaNode to the list of Controllers under this Player's
management.
|
protected void |
addNode(Controller node,
boolean optional)
Add a MediaNode to the list of Controllers under this Player's
management.
|
protected void |
allocBuffers()
Called during prefetch to allocate any necessary buffers.
|
protected abstract boolean |
audioEnabled()
Return true if the player is currently playing media
with an audio track.
|
void |
close()
Close the player to stop all threads to make * it "finalizable".
|
protected void |
completePrefetch()
Called as a last step to complete the prefetch call.
|
protected void |
completeRealize()
Called as a last step to complete the realize call.
|
protected abstract boolean |
connectNodes()
This is invoked from doRealize() after all the nodes created in
createNode() is fully realized.
|
protected void |
createGainControl()
If the Player can play audio, a gain control adapter is created
and the player is registered a listener for gain change events
|
protected abstract boolean |
createNodes()
This is invoked from doRealize() during the player realization stage.
|
protected boolean |
deviceBusy(MediaController mc)
Check the given controller to see if it's busy or not.
|
protected void |
doClose()
This is called when close() is invoked on the Player.
|
protected void |
doFailedPrefetch()
Called when prefetch fails.
|
protected void |
doFailedRealize()
Called when realize fails.
|
protected boolean |
doPrefetch()
The stub function to perform the steps to prefetch the controller.
|
protected boolean |
doRealize()
The stub function (invoked from realize()) to perform the steps to
realize the player.
|
protected void |
doSetMediaTime(Time now)
Called from setMediaTime.
|
protected float |
doSetRate(float factor)
Called from setRate.
|
protected void |
doStart()
Invoked by start() or syncstart().
|
protected void |
doStop()
The stop() method calls doStop() so that subclasses can
add additional behavior.
|
protected void |
flush()
This should trigger a flush to the data path.
|
void |
gainChange(GainChangeEvent gce)
Subclass should override this method to change the audio gain.
|
Component |
getControlPanelComponent()
Get the Component with the default user interface for controlling
this player.
|
Control[] |
getControls()
Return the controls that have been added (atleast includes the
playback control)
|
Time |
getDuration()
Get the duration of the media.
|
GainControl |
getGainControl()
Get the object for controlling audio gain.
|
protected abstract TimeBase |
getMasterTimeBase()
This should be implemented by the subclass.
|
Vector |
getNodeList()
Return the list of MediaControllers supported by this Player.
|
protected DataSource |
getSource()
Get the DataSource used by this player.
|
Component |
getVisualComponent()
Get the Component this player will output its visual media to.
|
void |
muteChange(boolean m)
Subclass should override this method to implement the mute behavior.
|
protected void |
processEvent(ControllerEvent evt)
Process one event from another Controller which we are listening to.
|
void |
removeController(Controller oldController)
Removes the controller from the list of controlled controllers and
sets the controller to its default time base.
|
protected void |
removeNode(Controller node)
Remove a MediaNode from the list of Controllers under this Player's
management.
|
protected void |
setMediaLength(long t)
Set the upper bound of the media time.
|
void |
setMediaTime(Time now)
Loops through the list of nodes and controllers maintained by this
player and invoke setMediaTime on each of them.
|
float |
setRate(float rate)
Set the playback rate on the player.
|
void |
setSource(DataSource source)
Set the DataSource that provides the media for this player.
|
void |
setStopTime(Time t)
sets up the specified stop time for all controllers in the
internal node list
|
void |
setTimeBase(TimeBase tb)
Assigns a timebase for the player.
|
void |
setVisualComponent(Component component,
Rectangle bounds)
Set the Component this player will output its visual media to.
|
protected void |
slaveToMasterTimeBase(TimeBase tb)
Slave all the controllers to the master time base.
|
void |
start()
Start the Player as soon as possible.
|
void |
stop()
requests to stop the player by delegating to stop(String request)
method.
|
protected void |
stop(String request)
stops the player.
|
protected void |
stopAtTime()
stops the player because of the specified stop time has passed.
|
boolean |
synchronousPrefetch()
Prefetch the player and block until it's been prefetched or if it fails.
|
boolean |
synchronousRealize()
Realize the player and block until it's been realized or if it fails.
|
void |
syncStart(Time tbt)
Start at the given time base time.
|
protected void |
updateDuration()
updates player's duration.
|
protected abstract boolean |
videoEnabled()
Return true if the player is currently playing media
with a video track.
|
addControllerListener, cleanup, controllerUpdate, deallocate, dispatchEvent, doDeallocate, getControl, getMediaClockTime, getMediaNanoseconds, getMediaTime, getRate, getStartLatency, getState, getStopTime, getSyncTime, getTargetState, getTimeBase, mapToTimeBase, prefetch, realize, removeControllerListener, sendEvent, setTargetStateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddControllerListener, deallocate, getControl, getStartLatency, getState, getTargetState, prefetch, realize, removeControllerListenergetMediaNanoseconds, getMediaTime, getRate, getStopTime, getSyncTime, getTimeBase, mapToTimeBasepublic static String VERSION
protected DataSource source
protected static TimeBase systemTimeBase
protected Control[] controls
protected GainControl gainControl
public static ColorModel defaultColorModel
public MediaPlayer()
public void setSource(DataSource source) throws IOException, IncompatibleSourceException
setSource in interface MediaHandlersource - of media for this player.IOException - thrown when an i/o error occurs
in reading information from the data source.IncompatibleSourceException - thrown if the Player can't use this source.protected DataSource getSource()
public final void close()
close in interface Controllerclose in class MediaControllerprotected void doClose()
doClose in class MediaControllerpublic void setTimeBase(TimeBase tb) throws IncompatibleTimeBaseException
setTimeBase in interface ClocksetTimeBase in class MediaControllertb - time base to be used by the Player.IncompatibleTimeBaseException - thrown when a time base other
than the master time base is set when audio is enabled.protected void setMediaLength(long t)
setMediaLength in class MediaControllerduration - the duration in nanoseconds.public Time getDuration()
getDuration in interface DurationgetDuration in class MediaControllerprotected void updateDuration()
public void setStopTime(Time t)
setStopTime in interface ClocksetStopTime in class MediaControllert - stop timepublic final void setMediaTime(Time now)
setMediaTime in interface ClocksetMediaTime in class MediaControllernow - the target media time.protected void doSetMediaTime(Time now)
now - the target media time.public void setVisualComponent(Component component, Rectangle bounds)
component - the component the player will use for displaying.bounds - the bounding rect the player uses for displaying.public Component getVisualComponent()
getVisualComponent in interface Playerpublic Component getControlPanelComponent()
getControlPanelComponent in interface Playerpublic GainControl getGainControl()
getGainControl in interface Playerpublic void gainChange(GainChangeEvent gce)
gainChange in interface GainChangeListenergce - the GainChangeEvent specifying the new gain level to set to.public void muteChange(boolean m)
m - the boolean value: true muted, false unmuted.public void addControls(Control[] newControls)
newControls - list of controls to add to the player.public Control[] getControls()
getControls in interface ControllergetControls in class MediaControllerpublic final Vector getNodeList()
public final void start()
This is a "final" method. Subclasses should override doStart() to implement its own specific behavior.
public final void syncStart(Time tbt)
This is a "final" method. Subclasses should override doStart() to implement its own specific behavior.
syncStart in interface ClocksyncStart in class MediaControllertbt - the time base time to start the player.protected void doStart()
doStart in class MediaControllerpublic final boolean synchronousRealize()
public final boolean synchronousPrefetch()
protected void doStop()
doStop in class MediaControllerpublic final void stop()
stop in interface Clockstop in class MediaControllerprotected void stopAtTime()
stopAtTime in class MediaControllerprotected void stop(String request)
request - specifies the type of stop request. Possible types of
the request are StopAtTime, StopByRequest, and restarting. Corresponding
events notifying that player has been stoped are sent to all listeners.protected final void addNode(Controller node)
protected final void addNode(Controller node, boolean optional)
protected final void removeNode(Controller node)
node - a controller removed from the list of nodespublic final void addController(Controller newController) throws IncompatibleTimeBaseException
Note: It is undefined what will happen if a Controller is under the control of a Player and any of the Controller's methods are called outside of the controlling Player.
addController in interface PlayernewController - the Controller this
Player will control.IncompatibleTimeBaseException - thrown if the new controller
will not accept the player's timebase.public final void removeController(Controller oldController)
removeController in interface PlayeroldController - the Controller to stop controlling.protected abstract boolean createNodes()
In addition, this method should also choose a master timebase to be used by this player. This should be returned on a getMasterTimeBase() call.
It should return success/failure. A subsequent call to createNodes() after the first successful completion should just return true.
protected abstract boolean connectNodes()
protected abstract boolean audioEnabled()
protected abstract boolean videoEnabled()
protected abstract TimeBase getMasterTimeBase()
protected boolean doRealize()
doRealize in class MediaControllerprotected void createGainControl()
protected void completeRealize()
completeRealize in class MediaControllerprotected void doFailedRealize()
doFailedRealize in class MediaControllerprotected void completePrefetch()
completePrefetch in class MediaControllerprotected void doFailedPrefetch()
doFailedPrefetch in class MediaControllerprotected final void abortRealize()
abortRealize in class MediaControllerprotected void allocBuffers()
protected boolean doPrefetch()
doPrefetch in class MediaControllerprotected final void abortPrefetch()
abortPrefetch in class MediaControllerprotected void flush()
protected boolean deviceBusy(MediaController mc)
protected void slaveToMasterTimeBase(TimeBase tb) throws IncompatibleTimeBaseException
tb - the time base to be used by all controllers.IncompatibleTimeBaseException - thrown if any controller
will not accept the player's timebase.protected void processEvent(ControllerEvent evt)
MediaControllerprocessEvent in class MediaControllerevt - controller event to be processedprotected float doSetRate(float factor)
doSetRate in class MediaControllerfactor - the rate to set to.
return the actual rate should be returnedpublic float setRate(float rate)
setRate in interface ClocksetRate in class MediaControllerrate - the rate to be setCopyright © 2012 code4tv.com. All Rights Reserved.