public abstract class AbstractMediaPlayer extends com.google.gwt.user.client.ui.Composite implements HasMediaStateHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyUpHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers
Constructor and Description |
---|
AbstractMediaPlayer()
Constructor method.
|
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addDebugHandler(DebugHandler handler)
Adds the specified debug handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler)
Adds the key down handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler)
Adds the key press handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler)
Adds the key up handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addLoadingProgressHandler(LoadingProgressHandler handler)
Adds the specified loading progress handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addMediaInfoHandler(MediaInfoHandler handler)
Adds the specified MediaInfo handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler)
Adds the mouse down handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler handler)
Adds the mouse move handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler handler)
Adds the mouse up handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addPlayerStateHandler(PlayerStateHandler handler)
Adds the specified player-state handler to the player
|
com.google.gwt.event.shared.HandlerRegistration |
addPlayStateHandler(PlayStateHandler handler)
Adds the specified play-state handler to the player
|
protected void |
addToPlayerReadyCommandQueue(String key,
com.google.gwt.user.client.Command command)
Adds the specified command to this players' command queue.
|
protected void |
fireDebug(String message)
Convenience method to fire
DebugEvent 's with informational messages
on registered handlers. |
protected void |
fireError(String description)
Convenience method to fire error type
DebugEvent 's on registered handlers. |
protected void |
fireLoadingProgress(double progress)
Convenience method to fire
LoadingProgressEvent 's on registered handlers. |
protected void |
fireMediaInfoAvailable(MediaInfo info)
Convenience method to fire
MediaInfoEvent 's on registered handlers. |
protected void |
firePlayerStateEvent(PlayerStateEvent.State state)
Convenience method to fire
PlayerStateEvent 's on registered handlers. |
protected void |
firePlayStateEvent(PlayStateEvent.State state,
int itemIndex)
Convenience method to fire
PlayStateEvent 's on registered handlers. |
int |
getLoopCount()
Returns the number of times this player repeats playback before stopping.
|
abstract long |
getMediaDuration()
Returns the duration of the loaded media in milliseconds.
|
abstract double |
getPlayPosition()
Gets the current position in the media that is being played.
|
double |
getRate()
Returns the current playback rate
|
RepeatMode |
getRepeatMode()
Returns the current playback repeat mode
|
int |
getVideoHeight()
Returns the height of the current media
|
int |
getVideoWidth()
Returns the width of the current media
|
abstract double |
getVolume()
Gets the volume ranging from
0 (silent) to 1 (full volume). |
protected PlayerProviderFactory |
getWidgetFactory(String providerName)
Returns a reference to the PlayerProviderFactory implementation with the
specified
providerName |
boolean |
isControllerVisible()
Checks whether the player controls are visible.
|
protected static boolean |
isPlayerOnPage(String playerId)
Checks if the player plugin with the specified playerId is attached to the
browsers' DOM
|
boolean |
isResizeToVideoSize()
Checks if player is set to adjust its size to match the dimensions of a video.
|
abstract void |
loadMedia(String mediaURL)
Loads the media at the specified URL into the player.
|
abstract void |
pauseMedia()
Pause the media playback
|
abstract void |
playMedia()
Plays the media loaded into the player.
|
protected void |
removeFromPlayerReadyCommandQueue(String key)
Removes a queued command with the specified
key from this players'
command queue. |
<C extends ConfigParameter> |
setConfigParameter(C param,
Object value)
Sets the specified player parameter to the specified value IF AND ONLY IF the
parameter is applicable on the player
|
void |
setControllerVisible(boolean show)
Displays or hides the player controls.
|
void |
setLoopCount(int loop)
Sets the number of times the current media file should repeat playback before stopping.
|
abstract void |
setPlayPosition(double position)
Sets the playback position of the current media
|
void |
setRate(double rate)
Sets the playback rate.
|
void |
setRepeatMode(RepeatMode mode)
Puts the player in the specified repeat mode.
|
void |
setResizeToVideoSize(boolean resize)
If the current media is a video, sets the player to adjust its size to match the
dimensions of the video
|
abstract void |
setVolume(double volume)
Sets the volume.
|
abstract void |
stopMedia()
Stops the media playback.
|
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, render, render, resolvePotentialElement, setWidget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
public abstract void loadMedia(String mediaURL) throws LoadException
In respect of the same domain
policy of some plugins,
the URL should point to a destination on the same domain
where the application is hosted.
mediaURL
- the URL of the media to load into the player.LoadException
- if an error occurs while loading the mediaIllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract void playMedia() throws PlayException
PlayException
- if an error occurs
during media playback.IllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract void stopMedia()
IllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract void pauseMedia()
IllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract long getMediaDuration()
IllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract double getPlayPosition()
IllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract void setPlayPosition(double position)
position
- the new position from where to start playbackIllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract double getVolume()
0
(silent) to 1
(full volume).IllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.public abstract void setVolume(double volume)
volume
- 0
(silent) to 1
(full volume).IllegalStateException
- if the player is not available, this is the case
if the player is not attached to the DOM.protected final void firePlayStateEvent(PlayStateEvent.State state, int itemIndex)
PlayStateEvent
's on registered handlers.state
- the state of the playerPlayStateEvent
protected final void firePlayerStateEvent(PlayerStateEvent.State state)
PlayerStateEvent
's on registered handlers.state
- the state of the playerPlayerStateEvent
protected final void fireError(String description)
DebugEvent
's on registered handlers.description
- the description of the errorDebugEvent
protected final void fireDebug(String message)
DebugEvent
's with informational messages
on registered handlers.message
- the messageDebugEvent
protected final void fireLoadingProgress(double progress)
LoadingProgressEvent
's on registered handlers.progress
- the progress of the loading operationLoadingProgressEvent
protected final void fireMediaInfoAvailable(MediaInfo info)
MediaInfoEvent
's on registered handlers.info
- the metadata of the loaded mediaMediaInfoEvent
public void setControllerVisible(boolean show)
show
- true
to make the player controls visible, false
otherwise.public boolean isControllerVisible()
true
if player controls are visible, false
otherwise.public void setLoopCount(int loop)
NB: As of version 1.2, the behaviour of this property depends on
the setRepeatMode(RepeatMode)
property
loop
- number of times to repeat playback. A negative value makes playback repeat forever!.public int getLoopCount()
0
, subclasses should override and implement
accordingly.protected final void addToPlayerReadyCommandQueue(String key, com.google.gwt.user.client.Command command)
The execution of the commands is tied to the Ready
state of the
PlayerState
event of the underlying plugin.
All scheduled commands are executed exactly once.
Note: If multiple commands use the same key, only the last command is executed.
key
- key with which the specified command is to be associatedcommand
- the command to execute when the player plugin is ready for interactionprotected final void removeFromPlayerReadyCommandQueue(String key)
key
from this players'
command queue.key
- key whose command is to be removedaddToPlayerReadyCommandQueue(java.lang.String, com.google.gwt.user.client.Command)
public final com.google.gwt.event.shared.HandlerRegistration addLoadingProgressHandler(LoadingProgressHandler handler)
addLoadingProgressHandler
in interface HasMediaProgressHandlers
handler
- the handlerLoadingProgressHandler
public final com.google.gwt.event.shared.HandlerRegistration addMediaInfoHandler(MediaInfoHandler handler)
addMediaInfoHandler
in interface HasMediaMessageHandlers
handler
- the handlerMediaInfoHandler
public final com.google.gwt.event.shared.HandlerRegistration addPlayStateHandler(PlayStateHandler handler)
addPlayStateHandler
in interface HasPlayStateHandlers
handler
- the handlerPlayStateHandler
public final com.google.gwt.event.shared.HandlerRegistration addPlayerStateHandler(PlayerStateHandler handler)
addPlayerStateHandler
in interface HasPlayStateHandlers
handler
- the handlerPlayerStateHandler
public final com.google.gwt.event.shared.HandlerRegistration addDebugHandler(DebugHandler handler)
addDebugHandler
in interface HasMediaMessageHandlers
handler
- the handlerDebugHandler
public void setResizeToVideoSize(boolean resize)
resize
- true
if player should adjust its size,
false
otherwisepublic boolean isResizeToVideoSize()
true
if player adjusts its size, false
otherwisepublic int getVideoHeight()
public int getVideoWidth()
protected static final boolean isPlayerOnPage(String playerId)
This method is provided for the convenience of player implementation classes.
playerId
- the object ID of the player plugintrue
if player plugin is attached, false
otherwise.public <C extends ConfigParameter> void setConfigParameter(C param, Object value)
Note: The parameter-value pairs are applied as HTML param tags on the underlying player plugin, therefore this method should be called before adding this player to a panel otherwise the method call will have no effect.
C
- the paramter value typeparam
- the configuration parametervalue
- the parameter valueIllegalArgumentException
- if value
is not of the required typepublic void setRate(double rate)
If this player is not available on the panel, this method call is added to the command-queue for later execution.
rate
- the playback rate. A rate of 1 implies normal playback rate,
fractional values are slow motion, and values greater than one are fast-forwardpublic double getRate()
setRate(double)
public com.google.gwt.event.shared.HandlerRegistration addMouseMoveHandler(com.google.gwt.event.dom.client.MouseMoveHandler handler)
addMouseMoveHandler
in interface com.google.gwt.event.dom.client.HasMouseMoveHandlers
handler
- the handlerpublic com.google.gwt.event.shared.HandlerRegistration addMouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler handler)
addMouseDownHandler
in interface com.google.gwt.event.dom.client.HasMouseDownHandlers
handler
- the handlerpublic com.google.gwt.event.shared.HandlerRegistration addMouseUpHandler(com.google.gwt.event.dom.client.MouseUpHandler handler)
addMouseUpHandler
in interface com.google.gwt.event.dom.client.HasMouseUpHandlers
handler
- the handlerpublic com.google.gwt.event.shared.HandlerRegistration addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler)
addKeyDownHandler
in interface com.google.gwt.event.dom.client.HasKeyDownHandlers
handler
- the handlerpublic com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler)
addKeyUpHandler
in interface com.google.gwt.event.dom.client.HasKeyUpHandlers
handler
- the handlerpublic com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler)
addKeyPressHandler
in interface com.google.gwt.event.dom.client.HasKeyPressHandlers
handler
- the handlerpublic void setRepeatMode(RepeatMode mode)
The effect of the specified mode depends on the setLoopCount(int)
property as
shown in the table:
Value of loopCount |
Value of repeatMode |
What it means? |
---|---|---|
Any value < 0 | Sets repeatMode to RepeatMode.REPEAT_ALL |
Playlist is repeated continously |
1 | RepeatMode.REPEAT_OFF |
Entire playlist is played only once |
RepeatMode.REPEAT_ONE |
The current playlist entry is repeated continously | |
RepeatMode.REPEAT_ALL |
Entire playlist is repeated continously | |
Any value > 1 | RepeatMode.REPEAT_OFF |
The loopCount property is ignored, and the entire playlist is played only once |
RepeatMode.REPEAT_ONE |
Player repeats each playlist entry for the number of times specified by loopCount
and moves on the next until all entries are played and stops |
|
RepeatMode.REPEAT_ALL |
Player repeats entire playlist for the number of times specified by loopCount and stops |
mode
- the new repeat modeRepeatMode
public RepeatMode getRepeatMode()
RepeatMode
protected final PlayerProviderFactory getWidgetFactory(String providerName)
providerName
This method is provided for the convenience of player implementation classes.
providerName
- the provider nameproviderName
or null
if no such provider exists.Copyright © 2009-2013. All Rights Reserved.