Copyright 2011-01-06 Werner Randelshofer

ch.randelshofer.media
Interface Player

All Superinterfaces:
StateModel
All Known Subinterfaces:
ColorCyclePlayer
All Known Implementing Classes:
AbstractPlayer, ANIMPlayer, PBMPlayer, SEQPlayer

public interface Player
extends StateModel

Generic interface for media players.

Version:
1.4 2009-12-25 Methods for color cycling added.
1.3 2003-04-21 Method setAudioEnabled() and isAudioEnabled() added.
1.2 2002-02-06 ChangeListener methods added.
1.1 2000-10-02 Methods #setPaused and #isPaused removed.
1.0 1999-10-19
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Immensee, Switzerland

Field Summary
static int CLOSED
          A player with this state has been explicitly closed or has encountered an error and can not be used any more.
static int PREFETCHED
          When a Player finishes Prefetching, it moves into the Prefetched state.
static int PREFETCHING
          When prefetch is called, a Player moves from the Realized state into the Prefetching state.
static int REALIZED
          When a Player finishes realizing it moves into the REALIZED state.
static int REALIZING
          When realize is called, a Player moves from the UNREALIZED state into the REALIZING state.
static int STARTED
          Calling start puts a Player into the Started state.
static int UNREALIZED
          A Player in the UNREALIZED state has been instantiated, but does not yet know anything about its media.
 
Method Summary
 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 that wants to be notified about property changes of the player.
 void addStateListener(StateListener listener)
          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
 javax.swing.BoundedRangeModel getCachingModel()
          Gets the model representing the realizing progress of the player.
 java.awt.Component getControlPanelComponent()
           
 int getState()
          Gets the current state of the player.
 int getTargetState()
          Gets the target state.
 javax.swing.BoundedRangeModel getTimeModel()
          Gets the model representing the time line of the player.
 long getTotalDuration()
           
 java.awt.Component getVisualComponent()
           
 boolean isActive()
          Returns true when the target state of the player is equal to STARTED.
 boolean isAudioAvailable()
          Returns true if audio is available.
 boolean isAudioEnabled()
          Returns true if audio is enabled.
 boolean isCached()
          Returns true when the player has completely cached all movie data.
 void prefetch()
          Initiates the following asynchronous state transitions: unrealized -> realizing -> realized -> prefetching -> prefetched realizing -> realized -> prefetching -> prefetched realized -> prefetching -> prefetched prefetching -> prefetched prefetched closed -> throws IllegalStateException
 void realize()
          Initiates the following asynchronous state transitions: unrealized -> realizing -> realized realizing -> realized realized closed -> throws IllegalStateException
 void removeChangeListener(javax.swing.event.ChangeListener listener)
          Removes a listener.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a listener.
 void removeStateListener(StateListener listener)
          Removes a listener.
 void setAudioEnabled(boolean b)
          Sets the audio enabled state.
 void setTargetState(int state)
          Sets the target state we want the player to be in.
 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
 

Field Detail

UNREALIZED

static final int UNREALIZED
A Player in the UNREALIZED state has been instantiated, but does not yet know anything about its media. When a media Player is first created, its unrealized.

See Also:
Constant Field Values

REALIZING

static final int REALIZING
When realize is called, a Player moves from the UNREALIZED state into the REALIZING state. A realizing player is in the process of determining its resource requirements. During realization, a Player acquires the resources that it only needs to acquire once. These might include rendering resources other than exclusive-use resources. (Exclusive-use resources are limited resources such as particular hardware devices that can only be used by one Player at a time; such resources are qcquired during PREFETCHING.) A realizing Player often downlaods assets over the net.

See Also:
Constant Field Values

REALIZED

static final int REALIZED
When a Player finishes realizing it moves into the REALIZED state. A realized Player knows what resoures it needs and information about the type of media it is to present. Because a realized Player knows how to render its data, it can provide visual components and controls. Its connections to other objects in the system are in place, but it does noct own any resources that would prevent another Player from starting.

See Also:
Constant Field Values

PREFETCHING

static final int PREFETCHING
When prefetch is called, a Player moves from the Realized state into the Prefetching state. A Prefetching Player is preparing to present its media. During this phase, the Player preloads its media data, obtains exclusive-use resources, and anything else it needs to do to prepare itself to play. Prefetching might have to recur if a Player's media presentation is repositioned, or if a change in the Player's rate requires that additional buffers be acquired or alternate processing take place.

See Also:
Constant Field Values

PREFETCHED

static final int PREFETCHED
When a Player finishes Prefetching, it moves into the Prefetched state. A Prefetched Player is ready to be started; it is as ready to play as it can be without actually being Started.

See Also:
Constant Field Values

STARTED

static final int STARTED
Calling start puts a Player into the Started state. A Started Player's time-base time and media time are mapped and its clock is running, though the Player might be waiting for a particular time to begin presenting its media data.

See Also:
Constant Field Values

CLOSED

static final int CLOSED
A player with this state has been explicitly closed or has encountered an error and can not be used any more.

See Also:
Constant Field Values
Method Detail

setAudioEnabled

void setAudioEnabled(boolean b)
Sets the audio enabled state.


isAudioEnabled

boolean isAudioEnabled()
Returns true if audio is enabled.


isAudioAvailable

boolean isAudioAvailable()
Returns true if audio is available.


getState

int getState()
Gets the current state of the player.

Specified by:
getState in interface StateModel

getTargetState

int getTargetState()
Gets the target state.


setTargetState

void setTargetState(int state)
Sets the target state we want the player to be in.


realize

void realize()
Initiates the following asynchronous state transitions: unrealized -> realizing -> realized realizing -> realized realized closed -> throws IllegalStateException


prefetch

void prefetch()
Initiates the following asynchronous state transitions: unrealized -> realizing -> realized -> prefetching -> prefetched realizing -> realized -> prefetching -> prefetched realized -> prefetching -> prefetched prefetching -> prefetched prefetched closed -> throws IllegalStateException


deallocate

void deallocate()
Initiates the following asynchronous state transitions: realizing -> unrealized prefetching -> realized prefetched -> realized realized started -> throws IllegalStateException closed -> throws IllegalStateException


start

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

void stop()
Initiates the following asynchronous state transitions: started -> prefetched unrealized realizing prefetching prefetched closed -> throws IllegalStateException


close

void close()
Initiates the following asynchronous state transitions: any state -> closed


addStateListener

void addStateListener(StateListener listener)
Adds a listener that wants to be notified about state changes of the player.

Specified by:
addStateListener in interface StateModel

removeStateListener

void removeStateListener(StateListener listener)
Removes a listener.

Specified by:
removeStateListener in interface StateModel

addChangeListener

void addChangeListener(javax.swing.event.ChangeListener listener)
Adds a listener that wants to be notified about state changes of the player.


removeChangeListener

void removeChangeListener(javax.swing.event.ChangeListener listener)
Removes a listener.


addPropertyChangeListener

void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener that wants to be notified about property changes of the player.


removePropertyChangeListener

void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener.


getTimeModel

javax.swing.BoundedRangeModel getTimeModel()
Gets the model representing the time line of the player.


getCachingModel

javax.swing.BoundedRangeModel getCachingModel()
Gets the model representing the realizing progress of the player.


isCached

boolean isCached()
Returns true when the player has completely cached all movie data. This player informs all property change listeners, when the value of this property changes. The name of the property is 'cached'.


getVisualComponent

java.awt.Component getVisualComponent()

getControlPanelComponent

java.awt.Component getControlPanelComponent()

getTotalDuration

long getTotalDuration()

isActive

boolean isActive()
Returns true when the target state of the player is equal to STARTED.


Copyright 2011-01-06 Werner Randelshofer