Class AbstractMedia
java.lang.Object
com.codename1.media.AbstractMedia
- All Implemented Interfaces:
AsyncMedia, Media
An abstract base class for AsyncMedia. Most media returned from
MediaManager will
be descendants of this class.-
Nested Class Summary
Nested classes/interfaces inherited from interface AsyncMedia
AsyncMedia.MediaErrorEvent, AsyncMedia.MediaErrorType, AsyncMedia.MediaException, AsyncMedia.MediaStateChangeEvent, AsyncMedia.PauseRequest, AsyncMedia.PlayRequest, AsyncMedia.State -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMediaCompletionHandler(Runnable onComplete) Adds a callback to be run when the media has played to completion.voidAdds a listener to be notified when an error occurs in the media.voidAdds a listener to be notified when the state of the media changes.protected AsyncMedia.MediaErrorEventFires a media error event to registered listeners.protected AsyncMedia.MediaStateChangeEventfireMediaStateChange(AsyncMedia.State newState) Fires a media state change event to the registered state change listeners.getState()Gets the current state of the media object.final voidpause()Pauses (actually stops) the playback or the recording of the media fileInitiates a pause request.protected abstract voidInitiates a pause request on the media.final voidplay()Starts playing or recording the media fileInitiates a play request.protected abstract voidplayImpl()Initiates a play request on the media.voidRemoves a listener so that it will no longer be notified of errors.voidRemoves a listener so that it will no longer be notified of state changes.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Media
cleanup, getDuration, getTime, getVariable, getVideoComponent, getVolume, isFullScreen, isNativePlayerMode, isPlaying, isVideo, prepare, setFullScreen, setNativePlayerMode, setTime, setVariable, setVolume
-
Constructor Details
-
AbstractMedia
public AbstractMedia()
-
-
Method Details
-
getState
Gets the current state of the media object.
Returns
The state of the media object.
- Specified by:
getStatein interfaceAsyncMedia
-
fireMediaStateChange
Fires a media state change event to the registered state change listeners.
Parameters
newState: The new state
Returns
The state change event.
-
addMediaStateChangeListener
Adds a listener to be notified when the state of the media changes.
Parameters
l: Listener
- Specified by:
addMediaStateChangeListenerin interfaceAsyncMedia
-
removeMediaStateChangeListener
Removes a listener so that it will no longer be notified of state changes.
Parameters
l: Listener
- Specified by:
removeMediaStateChangeListenerin interfaceAsyncMedia
-
fireMediaError
Fires a media error event to registered listeners.
Parameters
ex: The MediaException to deliver
Returns
The MediaErrorEvent object sent to listeners.
See also
-
#addMediaErrorListener(com.codename1.ui.events.ActionListener)
-
#removeMediaErrorListener(com.codename1.ui.events.ActionListener)
-
addMediaErrorListener
Adds a listener to be notified when an error occurs in the media.
Parameters
l: Listener
- Specified by:
addMediaErrorListenerin interfaceAsyncMedia
-
removeMediaErrorListener
Removes a listener so that it will no longer be notified of errors.
Parameters
l: Listener
- Specified by:
removeMediaErrorListenerin interfaceAsyncMedia
-
addMediaCompletionHandler
Adds a callback to be run when the media has played to completion.
Parameters
onComplete
- Specified by:
addMediaCompletionHandlerin interfaceAsyncMedia
-
playAsync
Initiates a play request. Returns immediately without blocking. Caller can use the returned PlayRequest object to be notified when playing has actually started.- Specified by:
playAsyncin interfaceAsyncMedia
-
pauseAsync
Initiates a pause request. Returns immediately without blocking. Caller can use the returned PauseRequest object to be notified when media has actually paused.- Specified by:
pauseAsyncin interfaceAsyncMedia
-
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
-
pause
-