public abstract class AbstractMedia

  1. Object
  2. AbstractMedia

ImplementsAsyncMedia, Media

An abstract base class for AsyncMedia. Most media returned from MediaManager will be descendants of this class.

Constructors

public AbstractMedia()

Methods

public AsyncMedia.State getState()Gets the current state of the media object.
protected AsyncMedia.MediaStateChangeEvent fireMediaStateChange(AsyncMedia.State newState)Fires a media state change event to the registered state change listeners.
public void addMediaStateChangeListener(ActionListener<AsyncMedia.MediaStateChangeEvent> l)Adds a listener to be notified when the state of the media changes.
public void removeMediaStateChangeListener(ActionListener<AsyncMedia.MediaStateChangeEvent> l)Removes a listener so that it will no longer be notified of state changes.
protected AsyncMedia.MediaErrorEvent fireMediaError(AsyncMedia.MediaException ex)Fires a media error event to registered listeners.
public void addMediaErrorListener(ActionListener<AsyncMedia.MediaErrorEvent> l)Adds a listener to be notified when an error occurs in the media.
public void removeMediaErrorListener(ActionListener<AsyncMedia.MediaErrorEvent> l)Removes a listener so that it will no longer be notified of errors.
public void addMediaCompletionHandler(Runnable onComplete)Adds a callback to be run when the media has played to completion.
public AsyncMedia.PlayRequest playAsync()Initiates a play request.
public AsyncMedia.PauseRequest pauseAsync()Initiates a pause request.
protected abstract void playImpl()Initiates a play request on the media.
protected abstract void pauseImpl()Initiates a pause request on the media.
public final void play()Starts playing or recording the media file
public final void pause()Pauses (actually stops) the playback or the recording of the media file

Inherited nested types

Inherited fields

Inherited methods

Constructor details

AbstractMedia

public AbstractMedia()

Method details

getState

public AsyncMedia.State getState()
Gets the current state of the media object.

Returns

The state of the media object.

fireMediaStateChange

protected AsyncMedia.MediaStateChangeEvent fireMediaStateChange(AsyncMedia.State newState)
Fires a media state change event to the registered state change listeners.

Parameters

newState AsyncMedia.State
The new state

Returns

The state change event.

addMediaStateChangeListener

public void addMediaStateChangeListener(ActionListener<AsyncMedia.MediaStateChangeEvent> l)
Adds a listener to be notified when the state of the media changes.

Parameters

l ActionListener<AsyncMedia.MediaStateChangeEvent>
Listener

removeMediaStateChangeListener

public void removeMediaStateChangeListener(ActionListener<AsyncMedia.MediaStateChangeEvent> l)
Removes a listener so that it will no longer be notified of state changes.

Parameters

l ActionListener<AsyncMedia.MediaStateChangeEvent>
Listener

fireMediaError

protected AsyncMedia.MediaErrorEvent fireMediaError(AsyncMedia.MediaException ex)
Fires a media error event to registered listeners.

Parameters

ex AsyncMedia.MediaException
The MediaException to deliver

Returns

The MediaErrorEvent object sent to listeners.

addMediaErrorListener

public void addMediaErrorListener(ActionListener<AsyncMedia.MediaErrorEvent> l)
Adds a listener to be notified when an error occurs in the media.

Parameters

l ActionListener<AsyncMedia.MediaErrorEvent>
Listener

removeMediaErrorListener

public void removeMediaErrorListener(ActionListener<AsyncMedia.MediaErrorEvent> l)
Removes a listener so that it will no longer be notified of errors.

Parameters

l ActionListener<AsyncMedia.MediaErrorEvent>
Listener

addMediaCompletionHandler

public void addMediaCompletionHandler(Runnable onComplete)
Adds a callback to be run when the media has played to completion.

playAsync

public AsyncMedia.PlayRequest playAsync()
Initiates a play request. Returns immediately without blocking. Caller can use the returned PlayRequest object to be notified when playing has actually started.

pauseAsync

public AsyncMedia.PauseRequest pauseAsync()
Initiates a pause request. Returns immediately without blocking. Caller can use the returned PauseRequest object to be notified when media has actually paused.

playImpl

protected abstract void playImpl()
Initiates a play request on the media.

pauseImpl

protected abstract void pauseImpl()
Initiates a pause request on the media.

play

public final void play()
Starts playing or recording the media file

pause

public final void pause()
Pauses (actually stops) the playback or the recording of the media file