java.lang.Object
org.monte.media.player.AbstractPlayer
- All Implemented Interfaces:
Runnable,Player,StateModel
Generic interface for media players.
- Author:
- Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SequentialDispatcherThe dispatcher.protected EventListenerListListener support.protected PropertyChangeSupportSupport for property change listeners.Fields inherited from interface org.monte.media.player.Player
CLOSED, PREFETCHED, PREFETCHING, REALIZED, REALIZING, STARTED, UNREALIZED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(ChangeListener listener) Adds a listener that wants to be notified about state changes of the player.voidAdds a listener who is interested in changes of this object.voidAdds a listener that wants to be notified about state changes of the player.voidclose()Initiates the following asynchronous state transitions: any state → closedvoidInitiates the following asynchronous state transitions: realizing → unrealized prefetching → realized prefetched → realized realized started → throws IllegalStateException closed → throws IllegalStateExceptionprotected abstract voiddoClosed()Does the work for the closed state.protected abstract voidDoes the work for the prefetched state.protected abstract voidDoes the work for the prefetching state.protected abstract voidDoes the work for the realized state.protected abstract voidDoes the work for the realizing state.protected abstract voidDoes the work for the started state.protected abstract voidDoes the work for the unrealized state.protected voidNotifies all registered change listeners.protected voidfireStateChanged(int newState) Notifies all registered state listeners and all registered change listeners.intgetState()Gets the current state of the player.intGets the target state.booleanisActive()Returns true when the target state of the player is equal to STARTED.voidprefetch()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 IllegalStateExceptionvoidrealize()Initiates the following asynchronous state transitions: unrealized → realizing → realized realizing → realized realized started → throws IllegalStateException closed → throws IllegalStateExceptionvoidremoveChangeListener(ChangeListener listener) Removes a listener.voidRemoves a previously registered listener.voidRemoves a listener.voidrun()Most of the real work goes here.voidsetTargetState(int state) Sets the desired target state.voidstart()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 IllegalStateExceptionvoidstop()Initiates the following asynchronous state transitions: started → prefetched unrealized realizing prefetching prefetched closed → throws IllegalStateExceptionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.monte.media.player.Player
getCachingModel, getControlPanelComponent, getTimeModel, getTotalDuration, getVisualComponent, isAudioAvailable, isAudioEnabled, isCached, setAudioEnabled
-
Field Details
-
listenerList
Listener support. -
propertyChangeSupport
Support for property change listeners. -
dispatcher
The dispatcher.
-
-
Constructor Details
-
AbstractPlayer
public AbstractPlayer()Creates a new instance.
-
-
Method Details
-
getState
public int getState()Gets the current state of the player.- Specified by:
getStatein interfacePlayer- Specified by:
getStatein interfaceStateModel
-
getTargetState
public int getTargetState()Gets the target state.- Specified by:
getTargetStatein interfacePlayer
-
setTargetState
public void setTargetState(int state) Sets the desired target state.- Specified by:
setTargetStatein interfacePlayer
-
realize
public void realize()Initiates the following asynchronous state transitions: unrealized → realizing → realized realizing → realized realized started → throws IllegalStateException closed → throws IllegalStateException -
prefetch
public 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 -
deallocate
public void deallocate()Initiates the following asynchronous state transitions: realizing → unrealized prefetching → realized prefetched → realized realized started → throws IllegalStateException closed → throws IllegalStateException- Specified by:
deallocatein interfacePlayer
-
start
public 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 -
stop
public void stop()Initiates the following asynchronous state transitions: started → prefetched unrealized realizing prefetching prefetched closed → throws IllegalStateException -
close
public void close()Initiates the following asynchronous state transitions: any state → closed -
addStateListener
Adds a listener that wants to be notified about state changes of the player.- Specified by:
addStateListenerin interfacePlayer- Specified by:
addStateListenerin interfaceStateModel
-
removeStateListener
Removes a listener.- Specified by:
removeStateListenerin interfacePlayer- Specified by:
removeStateListenerin interfaceStateModel
-
addPropertyChangeListener
Adds a listener who is interested in changes of this object.- Specified by:
addPropertyChangeListenerin interfacePlayer
-
removePropertyChangeListener
Removes a previously registered listener.- Specified by:
removePropertyChangeListenerin interfacePlayer
-
fireStateChanged
protected void fireStateChanged(int newState) Notifies all registered state listeners and all registered change listeners. -
fireStateChanged
protected void fireStateChanged()Notifies all registered change listeners. -
run
public void run()Most of the real work goes here. We have to decide when to post events like EndOfMediaEvent and StopAtTimeEvent and TimeLineEvent. -
doClosed
protected abstract void doClosed()Does the work for the closed state. -
doUnrealized
protected abstract void doUnrealized()Does the work for the unrealized state. -
doRealizing
protected abstract void doRealizing()Does the work for the realizing state. -
doRealized
protected abstract void doRealized()Does the work for the realized state. -
doPrefetching
protected abstract void doPrefetching()Does the work for the prefetching state. -
doPrefetched
protected abstract void doPrefetched()Does the work for the prefetched state. -
doStarted
protected abstract void doStarted()Does the work for the started state. -
addChangeListener
Adds a listener that wants to be notified about state changes of the player.- Specified by:
addChangeListenerin interfacePlayer
-
removeChangeListener
Removes a listener.- Specified by:
removeChangeListenerin interfacePlayer
-
isActive
public boolean isActive()Returns true when the target state of the player is equal to STARTED.
-