com.sun.media
类 BasicPlayer

java.lang.Object
  继承者 com.sun.media.BasicController
      继承者 com.sun.media.BasicPlayer
所有已实现的接口:
Clock, Controller, ControllerListener, DownloadProgressListener, Duration, MediaHandler, Player
直接已知子类:
BasicProcessor, MediaPlayer

public abstract class BasicPlayer
extends BasicController
implements Player, ControllerListener, DownloadProgressListener

BasicPlayer implements the bases of a javax.media.Player. It handles all the Player state transitions, event handling and management of any Controller under its control.


字段摘要
protected  javax.media.control.BufferControl bufferControl
           
protected  CachingControl cachingControl
           
protected  java.awt.Component controlComp
           
protected  java.util.Vector controllerList
           
protected  Control[] controls
           
protected  ExtendedCachingControl extendedCachingControl
           
protected  boolean framePositioning
           
 com.sun.media.controls.SliderRegionControl regionControl
           
protected  javax.media.protocol.DataSource source
           
static java.lang.String VERSION
           
 
从类 com.sun.media.BasicController 继承的字段
processError, state, stopThreadEnabled
 
从接口 javax.media.Controller 继承的字段
LATENCY_UNKNOWN, Prefetched, Prefetching, Realized, Realizing, Started, Unrealized
 
从接口 javax.media.Clock 继承的字段
RESET
 
从接口 javax.media.Duration 继承的字段
DURATION_UNBOUNDED, DURATION_UNKNOWN
 
构造方法摘要
BasicPlayer()
           
 
方法摘要
protected  void abortPrefetch()
          Called when the prefetch() is aborted, i.e. deallocate() was called while prefetching.
protected  void abortRealize()
          Called when the realize() is aborted, i.e. deallocate() was called while realizing.
 void addController(Controller newController)
          Assume control of another Controller.
protected abstract  boolean audioEnabled()
          Return true if the player is currently playing media with an audio track.
protected  void completeConfigure()
          Called as a last step to complete the configure call.
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  void controllerSetStopTime(Time t)
          This is for subclass to access Controller's implementation of setStopTime.
protected  void controllerStopAtTime()
          This is for subclass to access Controller's implementation of stopAtTime.
 void controllerUpdate(ControllerEvent evt)
          This get called when some Controller notifies this player of any event.
protected  boolean deviceBusy(BasicController 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  boolean doConfigure()
          The stub function (invoked from configure()) to perform the steps to configure the player.
protected  void doFailedConfigure()
          Called when configure fails.
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 configure()) to perform the steps to configure the player.
protected  void doSetMediaTime(Time now)
          Called from setMediaTime.
protected  float doSetRate(float factor)
           
protected  void doStart()
          Invoked by start() or syncstart().
protected  void doStop()
          The stop() method calls doStop() so that subclasses can add additional behavior.
 void downloadUpdate()
           
 java.lang.String getContentType()
           
 java.util.Vector getControllerList()
          Return the list of BasicControllers supported by this Player.
 java.awt.Component getControlPanelComponent()
          Get the Component with the default user interface for controlling this player.
 Control[] getControls()
          Return the list of controls from its slave controllers plus the ones that this player supports.
 Time getDuration()
          Get the duration of the movie.
 GainControl getGainControl()
          Get the object for controlling audio gain.
protected abstract  TimeBase getMasterTimeBase()
          This should be implemented by the subclass.
 MediaLocator getMediaLocator()
           
protected  javax.media.protocol.DataSource getSource()
          Get the DataSource used by this player.
 Time getStartLatency()
          Gets the Controller's start latency in nanoseconds.
 java.awt.Component getVisualComponent()
          Get the Component this player will output its visual media to.
 boolean isAboutToRestart()
          Return true if the player is about to restart again.
protected  boolean isConfigurable()
          A player is not configurable.
 boolean isFramePositionable()
          Will return true if the player can do frame positioning.
protected  void manageController(Controller controller)
          Add a Controller to the list of Controllers under this Player's management.
protected  void manageController(Controller controller, boolean optional)
          Add a Controller to the list of Controllers under this Player's management.
protected  void processEndOfMedia()
           
protected  void processEvent(ControllerEvent evt)
           
 void removeController(Controller oldController)
          Stop controlling a Controller.
protected  void setMediaLength(long t)
          Set the upper bound of the media time.
 void setMediaTime(Time now)
          Loops through the list of 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(javax.media.protocol.DataSource source)
          Set the DataSource that provides the media for this player.
 void setStopTime(Time t)
          Sets the media time at which you want the Clock to stop.
 void setTimeBase(TimeBase tb)
          Assigns a timebase for the player.
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()
          Stop the player.
protected  void stopAtTime()
          Stop because stop time has been reached.
 void syncStart(Time tbt)
          Start at the given time base time.
 void unmanageController(Controller controller)
          Remove a Controller from the list of Controllers under this Player's management.
protected  void updateDuration()
           
abstract  void updateStats()
          This is being called from a looping thread to update the stats.
protected abstract  boolean videoEnabled()
          Return true if the player is currently playing media with a video track.
 
从类 com.sun.media.BasicController 继承的方法
abortConfigure, addControllerListener, close, configure, deallocate, dispatchEvent, doDeallocate, getClock, getControl, getMediaNanoseconds, getMediaTime, getRate, getState, getStopTime, getSyncTime, getTargetState, getTimeBase, interrupt, isInterrupted, mapToTimeBase, prefetch, realize, removeControllerListener, resetInterrupt, sendEvent, setClock, setTargetState, stopControllerOnly, syncStartInProgress, throwError
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 javax.media.Controller 继承的方法
addControllerListener, close, deallocate, getControl, getState, getTargetState, prefetch, realize, removeControllerListener
 
从接口 javax.media.Clock 继承的方法
getMediaNanoseconds, getMediaTime, getRate, getStopTime, getSyncTime, getTimeBase, mapToTimeBase
 

字段详细信息

VERSION

public static java.lang.String VERSION

source

protected javax.media.protocol.DataSource source

controllerList

protected java.util.Vector controllerList

framePositioning

protected boolean framePositioning

controls

protected Control[] controls

controlComp

protected java.awt.Component controlComp

regionControl

public com.sun.media.controls.SliderRegionControl regionControl

cachingControl

protected CachingControl cachingControl

extendedCachingControl

protected ExtendedCachingControl extendedCachingControl

bufferControl

protected javax.media.control.BufferControl bufferControl
构造方法详细信息

BasicPlayer

public BasicPlayer()
方法详细信息

isFramePositionable

public boolean isFramePositionable()
Will return true if the player can do frame positioning. Hack for now, should be removed when players actually implement the framePositioning control.


isConfigurable

protected boolean isConfigurable()
A player is not configurable.

指定者:
BasicController 中的 isConfigurable

setSource

public void setSource(javax.media.protocol.DataSource source)
               throws java.io.IOException,
                      IncompatibleSourceException
Set the DataSource that provides the media for this player. BasicPlayer only supports PullDataSource by default. Subclasses can override this method to support other DataSources.

指定者:
接口 MediaHandler 中的 setSource
参数:
source - of media for this player.
抛出:
java.io.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.

downloadUpdate

public void downloadUpdate()
指定者:
接口 DownloadProgressListener 中的 downloadUpdate

getMediaLocator

public MediaLocator getMediaLocator()

getContentType

public java.lang.String getContentType()

getSource

protected javax.media.protocol.DataSource getSource()
Get the DataSource used by this player.

返回:
the DataSource used by this player.

doClose

protected void doClose()
This is called when close() is invoked on the Player. close() takes care of the general behavior before invoking doClose(). Subclasses should implement this only if it needs to do something specific to close the player.

覆盖:
BasicController 中的 doClose

setTimeBase

public void setTimeBase(TimeBase tb)
                 throws IncompatibleTimeBaseException
Assigns a timebase for the player. If the BasicPlayer plays back audio, the timebase can be none other than the master timebase as returned by getMasterTimeBase(). This is to ensure that we won't set to a timebase the audio cannot handle at this point. If the playback is video only, the timebase can be set to any timebase desired.

指定者:
接口 Clock 中的 setTimeBase
覆盖:
BasicController 中的 setTimeBase
参数:
tb - 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.

setMediaLength

protected void setMediaLength(long t)
Set the upper bound of the media time.

覆盖:
BasicController 中的 setMediaLength
参数:
duration - the duration in nanoseconds.

getDuration

public Time getDuration()
Get the duration of the movie.

指定者:
接口 Duration 中的 getDuration
覆盖:
BasicController 中的 getDuration
返回:
the duration of the movie.

updateDuration

protected void updateDuration()

getStartLatency

public Time getStartLatency()
从接口 Controller 复制的描述
Gets the Controller's start latency in nanoseconds. The start latency represents a worst-case estimate of the amount of time it will take to present the first frame of data.

This method is useful for determining how far in advance the syncStart method must be invoked to ensure that media will be rendered at the specified start time.

For a Controller that has a variable start latency, the value returned represents the maximum possible start latency. If you call getStartLatency on a Controller that isn't Prefetched and getStartLatency returns LATENCY_UNKNOWN, calling prefetch and then calling getStartLatency again after the Controller posts a PrefetchCompleteEvent might return a more accurate estimate. If getStartLatency still returns LATENCY_UNKNOWN, the start latency is indeterminate and you might not be able to use syncStart to synchronize the Controller with other Controllers.

Note: In most cases, the value returned by getStartLatency will change once the Controller is Prefetched.

指定者:
接口 Controller 中的 getStartLatency
覆盖:
BasicController 中的 getStartLatency
返回:
The time it will take before the first frame of media can be presented.

stopAtTime

protected void stopAtTime()
Stop because stop time has been reached. Subclasses should override this method.

覆盖:
BasicController 中的 stopAtTime

controllerStopAtTime

protected void controllerStopAtTime()
This is for subclass to access Controller's implementation of stopAtTime.


setStopTime

public void setStopTime(Time t)
从接口 Clock 复制的描述
Sets the media time at which you want the Clock to stop. The Clock will stop when its media time passes the stop-time. To clear the stop time, set it to: Clock.RESET.

You can always call setStopTime on a Stopped  Clock.

On a Started Clock, the stop-time can only be set once. A StopTimeSetError is thrown if setStopTime is called and the media stop-time has already been set.

指定者:
接口 Clock 中的 setStopTime
覆盖:
BasicController 中的 setStopTime
参数:
t - The time at which you want the Clock to stop, in media time.

controllerSetStopTime

protected void controllerSetStopTime(Time t)
This is for subclass to access Controller's implementation of setStopTime.


setMediaTime

public final void setMediaTime(Time now)
Loops through the list of controllers maintained by this player and invoke setMediaTime on each of them. This is a "final" method and cannot be overridden by subclasses.

指定者:
接口 Clock 中的 setMediaTime
覆盖:
BasicController 中的 setMediaTime
参数:
now - the target media time.

isAboutToRestart

public boolean isAboutToRestart()
Return true if the player is about to restart again.


doSetMediaTime

protected void doSetMediaTime(Time now)
Called from setMediaTime. This is used for subclasses to add in their own behavior.

覆盖:
BasicController 中的 doSetMediaTime
参数:
now - the target media time.

getVisualComponent

public java.awt.Component getVisualComponent()
Get the Component this player will output its visual media to. If this player has no visual component (e.g. audio only) getVisualComponent() will return null. Subclasses should override this method and return the visual component but call this method first to ensure that the restrictions on player methods are enforced.

指定者:
接口 Player 中的 getVisualComponent
返回:
the media display component.

getControlPanelComponent

public java.awt.Component getControlPanelComponent()
Get the Component with the default user interface for controlling this player. If this player has no default control panel null is returned. Subclasses should override this method and return the control panel component but call this method first to ensure that the restrictions on player methods are enforced.

指定者:
接口 Player 中的 getControlPanelComponent
返回:
the default control panel GUI.

getGainControl

public GainControl getGainControl()
Get the object for controlling audio gain. Return null if this player does not have a GainControl (e.g. no audio).

指定者:
接口 Player 中的 getGainControl
返回:
the GainControl object for this player.

getControls

public Control[] getControls()
Return the list of controls from its slave controllers plus the ones that this player supports.

指定者:
接口 Controller 中的 getControls
覆盖:
BasicController 中的 getControls
返回:
the list of controls supported by this player.

controllerUpdate

public final void controllerUpdate(ControllerEvent evt)
This get called when some Controller notifies this player of any event.

指定者:
接口 ControllerListener 中的 controllerUpdate
参数:
evt - The event generated.

getControllerList

public final java.util.Vector getControllerList()
Return the list of BasicControllers supported by this Player.

返回:
a vector of the BasicControllers supported by this Player.

start

public final void start()
Start the Player as soon as possible. Start attempts to transition the player into the started state. If the player has not been realized, or prefetched, then the equivalent of those actions will occur, and the appropriate events will be generated. If the implied realize or prefetch fail, a failure event will be generated and the Player will remain in one of the non-started states.

This is a "final" method. Subclasses should override doStart() to implement its own specific behavior.

指定者:
接口 Player 中的 start

syncStart

public final void syncStart(Time tbt)
Start at the given time base time. This overrides Clock.syncStart() and obeys all its semantics.

This is a "final" method. Subclasses should override doStart() to implement its own specific behavior.

指定者:
接口 Clock 中的 syncStart
覆盖:
BasicController 中的 syncStart
参数:
tbt - the time base time to start the player.

doStart

protected void doStart()
Invoked by start() or syncstart(). Called from a separate thread called TimedStart thread. subclasses can override this method to implement its specific behavior.

指定者:
BasicController 中的 doStart

doStop

protected void doStop()
The stop() method calls doStop() so that subclasses can add additional behavior.

覆盖:
BasicController 中的 doStop

stop

public final void stop()
Stop the player. If current state is Started, sends stop() to all the managed controllers, and waits for a StopEvent from all of them. It then sends a StopEvent to any listener(s).

指定者:
接口 Clock 中的 stop
覆盖:
BasicController 中的 stop

processEndOfMedia

protected final void processEndOfMedia()

manageController

protected final void manageController(Controller controller)
Add a Controller to the list of Controllers under this Player's management. This is a protected method use only by subclasses. Use addController() for public access.


manageController

protected final void manageController(Controller controller,
                                      boolean optional)
Add a Controller to the list of Controllers under this Player's management.


unmanageController

public final void unmanageController(Controller controller)
Remove a Controller from the list of Controllers under this Player's management. This is a protected method use only by subclasses. Use removeController() for public access.


addController

public void addController(Controller newController)
                   throws IncompatibleTimeBaseException
Assume control of another Controller. A Player can accept responsibility for controlling another Controller. Once a Controller has been added this Player will:

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.

指定者:
接口 Player 中的 addController
参数:
newController - the Controller this Player will control.
抛出:
IncompatibleTimeBaseException - thrown if the new controller will not accept the player's timebase.

removeController

public final void removeController(Controller oldController)
Stop controlling a Controller.

指定者:
接口 Player 中的 removeController
参数:
oldController - the Controller to stop controlling.

audioEnabled

protected abstract boolean audioEnabled()
Return true if the player is currently playing media with an audio track.

返回:
true if the player is playing audio.

videoEnabled

protected abstract boolean videoEnabled()
Return true if the player is currently playing media with a video track.

返回:
true if the player is playing video.

getMasterTimeBase

protected abstract TimeBase getMasterTimeBase()
This should be implemented by the subclass. The subclass method should return the master TimeBase -- the TimeBase that all other controllers slave to. Use SystemTimeBase if unsure.

返回:
the master time base.

doConfigure

protected boolean doConfigure()
The stub function (invoked from configure()) to perform the steps to configure the player. It performs the following: Subclasses are allowed to override doConfigure(). But this should be done in caution. Subclass should also invoke super.doConfigure(). This is called from a separately running thread.

覆盖:
BasicController 中的 doConfigure
返回:
true if successful.

completeConfigure

protected void completeConfigure()
Called as a last step to complete the configure call.

覆盖:
BasicController 中的 completeConfigure

doFailedConfigure

protected void doFailedConfigure()
Called when configure fails.

覆盖:
BasicController 中的 doFailedConfigure

doRealize

protected boolean doRealize()
The stub function (invoked from configure()) to perform the steps to configure the player. It performs the following: Subclasses are allowed to override doRealize(). But this should be done in caution. Subclass should also invoke super.doRealize(). This is called from a separately running thread.

指定者:
BasicController 中的 doRealize
返回:
true if successful.

completeRealize

protected void completeRealize()
Called as a last step to complete the realize call.

覆盖:
BasicController 中的 completeRealize

doFailedRealize

protected void doFailedRealize()
Called when realize fails.

覆盖:
BasicController 中的 doFailedRealize

completePrefetch

protected void completePrefetch()
Called as a last step to complete the prefetch call.

覆盖:
BasicController 中的 completePrefetch

doFailedPrefetch

protected void doFailedPrefetch()
Called when prefetch fails.

覆盖:
BasicController 中的 doFailedPrefetch

abortRealize

protected final void abortRealize()
Called when the realize() is aborted, i.e. deallocate() was called while realizing. Release all resources claimed previously by the realize() call.

指定者:
BasicController 中的 abortRealize

doPrefetch

protected boolean doPrefetch()
The stub function to perform the steps to prefetch the controller. This will call prefetch() on every controller in the controller list and wait for their completion events. This is called from a separately running thread.

指定者:
BasicController 中的 doPrefetch
返回:
true if successful.

abortPrefetch

protected final void abortPrefetch()
Called when the prefetch() is aborted, i.e. deallocate() was called while prefetching. Release all resources claimed previously by the prefetch call.

指定者:
BasicController 中的 abortPrefetch

deviceBusy

protected boolean deviceBusy(BasicController mc)
Check the given controller to see if it's busy or not. Needs to be overridden by subclass. The subclass method should change the master timebase if necessary. It should handle audio only or video only tracks properly when the device is busy.

返回:
true if the given controller is usable; false if the controller cannot be used.

slaveToMasterTimeBase

protected void slaveToMasterTimeBase(TimeBase tb)
                              throws IncompatibleTimeBaseException
Slave all the controllers to the master time base. The controllers should be in realized or greater state This differs from the setTimeBase() as it loops through each controllers and call setTimeBase on each of them.

参数:
tb - the time base to be used by all controllers.
抛出:
IncompatibleTimeBaseException - thrown if any controller will not accept the player's timebase.

processEvent

protected void processEvent(ControllerEvent evt)

doSetRate

protected float doSetRate(float factor)
覆盖:
BasicController 中的 doSetRate

setRate

public float setRate(float rate)
Set the playback rate on the player. It loops through its list of controllers and invoke setRate on each of them.

指定者:
接口 Clock 中的 setRate
覆盖:
BasicController 中的 setRate
参数:
rate - The temporal scale factor (rate) to set.
返回:
The actual rate set.

updateStats

public abstract void updateStats()
This is being called from a looping thread to update the stats.