public abstract class AbstractPlayer extends java.lang.Object implements Player, java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
protected SequentialDispatcher |
dispatcher
The dispatcher.
|
protected javax.swing.event.EventListenerList |
listenerList
Listener support.
|
protected java.beans.PropertyChangeSupport |
propertyChangeSupport
Support for property change listeners.
|
CLOSED, PREFETCHED, PREFETCHING, REALIZED, REALIZING, STARTED, UNREALIZED
Constructor and Description |
---|
AbstractPlayer()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(javax.swing.event.ChangeListener listener)
Adds a listener that wants to be notified about
state changes of the player.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener who is interested in changes of this object.
|
void |
addStateListener(StateListener l)
Adds a listener that wants to be notified about
state changes of the player.
|
void |
close()
Initiates the following asynchronous
state transitions:
any state -> closed
|
void |
deallocate()
Initiates the following asynchronous
state transitions:
realizing -> unrealized
prefetching -> realized
prefetched -> realized
realized
started -> throws IllegalStateException
closed -> throws IllegalStateException
|
protected abstract void |
doClosed()
Does the work for the closed state.
|
protected abstract void |
doPrefetched()
Does the work for the prefetched state.
|
protected abstract void |
doPrefetching()
Does the work for the prefetching state.
|
protected abstract void |
doRealized()
Does the work for the realized state.
|
protected abstract void |
doRealizing()
Does the work for the realizing state.
|
protected abstract void |
doStarted()
Does the work for the started state.
|
protected abstract void |
doUnrealized()
Does the work for the unrealized state.
|
protected void |
fireStateChanged()
Notifies all registered change listeners.
|
protected void |
fireStateChanged(int newState)
Notifies all registered state listeners and
all registered change listeners.
|
int |
getState()
Gets the current state of the player.
|
int |
getTargetState()
Gets the target state.
|
boolean |
isActive()
Returns true when the target state of the player is equal to STARTED.
|
void |
prefetch()
Initiates the following asynchronous
state transitions:
unrealized -> realizing -> realized -> prefetching -> prefetched
realizing -> realized -> prefetching -> prefetched
realized -> prefetching -> prefetched
prefetching -> prefetched
prefetched
started -> throws IllegalStateException
closed -> throws IllegalStateException
|
void |
realize()
Initiates the following asynchronous
state transitions:
unrealized -> realizing -> realized
realizing -> realized
realized
started -> throws IllegalStateException
closed -> throws IllegalStateException
|
void |
removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a listener.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a previously registered listener.
|
void |
removeStateListener(StateListener l)
Removes a listener.
|
void |
run()
Most of the real work goes here.
|
void |
setTargetState(int state)
Sets the desired target state.
|
void |
start()
Initiates the following asynchronous
state transitions:
unrealized -> realizing -> realized -> prefetching -> prefetched -> started
realizing -> realized -> prefetching -> prefetched -> started
realized -> prefetching -> prefetched -> started
prefetching -> prefetched -> started
prefetched -> started
started
closed -> throws IllegalStateException
|
void |
stop()
Initiates the following asynchronous
state transitions:
started -> prefetched
unrealized
realizing
prefetching
prefetched
closed -> throws IllegalStateException
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCachingModel, getControlPanelComponent, getTimeModel, getTotalDuration, getVisualComponent, isAudioAvailable, isAudioEnabled, isCached, setAudioEnabled
protected javax.swing.event.EventListenerList listenerList
protected java.beans.PropertyChangeSupport propertyChangeSupport
protected SequentialDispatcher dispatcher
public int getState()
getState
in interface Player
getState
in interface StateModel
public int getTargetState()
getTargetState
in interface Player
public void setTargetState(int state)
setTargetState
in interface Player
public void realize()
public void prefetch()
public void deallocate()
deallocate
in interface Player
public void start()
public void stop()
public void close()
public void addStateListener(StateListener l)
addStateListener
in interface Player
addStateListener
in interface StateModel
public void removeStateListener(StateListener l)
removeStateListener
in interface Player
removeStateListener
in interface StateModel
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface Player
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface Player
protected void fireStateChanged(int newState)
protected void fireStateChanged()
public void run()
run
in interface java.lang.Runnable
protected abstract void doClosed()
protected abstract void doUnrealized()
protected abstract void doRealizing()
protected abstract void doRealized()
protected abstract void doPrefetching()
protected abstract void doPrefetched()
protected abstract void doStarted()
public void addChangeListener(javax.swing.event.ChangeListener listener)
addChangeListener
in interface Player
public void removeChangeListener(javax.swing.event.ChangeListener listener)
removeChangeListener
in interface Player