|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.gwt.user.client.ui.UIObject com.google.gwt.user.client.ui.Widget com.google.gwt.user.client.ui.Composite com.bramosystems.oss.player.core.client.AbstractMediaPlayer com.bramosystems.oss.player.core.client.ui.DivXPlayer
public class DivXPlayer
Widget to embed DivX® Web Player plugin.
SimplePanel panel = new SimplePanel(); // create panel to hold the player
Widget player = null;
try {
// create the player
player = new DivXPlayer("www.example.com/mediafile.divx");
} catch(LoadException e) {
// catch loading exception and alert user
Window.alert("An error occured while loading");
} catch(PluginVersionException e) {
// catch plugin version exception and alert user to download plugin first.
// An option is to use the utility method in PlayerUtil class.
player = PlayerUtil.getMissingPluginNotice(Plugin.DivXPlayer, "Missing Plugin",
".. some nice message telling the user to click and download plugin first ..",
false);
} catch(PluginNotFoundException e) {
// catch PluginNotFoundException and tell user to download plugin, possibly providing
// a link to the plugin download page.
player = new HTML(".. another kind of message telling the user to download plugin..");
}
panel.setWidget(player); // add player to panel.
Nested Class Summary | |
---|---|
static class |
DivXPlayer.BufferingMode
An enum of buffering modes for DivXPlayer widget. |
static class |
DivXPlayer.DisplayMode
An enum of display modes for DivXPlayer widget. |
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
---|
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled |
Field Summary |
---|
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Constructor Summary | |
---|---|
DivXPlayer(java.lang.String mediaURL)
Constructs DivXPlayer to automatically playback media located at
mediaURL using the default height of 90px and width of 100%. |
|
DivXPlayer(java.lang.String mediaURL,
boolean autoplay)
Constructs DivXPlayer to playback media located at mediaURL using the
default height of 90px and width of 100%. |
|
DivXPlayer(java.lang.String mediaURL,
boolean autoplay,
java.lang.String height,
java.lang.String width)
Constructs DivXPlayer to playback media located at mediaURL using the
default height of 90px and width of 100%. |
Method Summary | |
---|---|
void |
addToPlaylist(java.util.List<MRL> mediaLocators)
Adds the media locators to the players' playlist. |
void |
addToPlaylist(MRL mediaLocator)
Adds the media locator to the players' playlist. |
void |
addToPlaylist(java.lang.String... mediaURLs)
Adds the media at the specified URLs to the players' playlist. |
void |
addToPlaylist(java.lang.String mediaURL)
Adds the media at the specified URL to the players' playlist. |
void |
clearPlaylist()
Removes all entries in the players' playlist |
DivXPlayer.DisplayMode |
getDisplayMode()
Returns the skin mode of the player which is used to display playback controls. |
int |
getLoopCount()
Returns the number of times this player repeats playback before stopping. |
long |
getMediaDuration()
Returns the duration of the loaded media in milliseconds. |
int |
getPlaylistSize()
Returns the number of entries in the playlist |
double |
getPlayPosition()
Gets the current position in the media that is being played. |
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 |
double |
getVolume()
Gets the volume ranging from 0 (silent) to 1 (full volume). |
boolean |
isControllerVisible()
Checks whether the player controls are visible. |
boolean |
isResizeToVideoSize()
Checks if player is set to adjust its size to match the dimensions of a video. |
boolean |
isShuffleEnabled()
Checks if this player is in shuffle mode. |
void |
loadMedia(java.lang.String mediaURL)
Loads the media at the specified URL into the player. |
protected void |
onLoad()
Overridden to register player for plugin DOM events |
protected void |
onUnload()
Overridden to release resources |
void |
pauseMedia()
Pause the media playback |
void |
play(int index)
Play playlist entry at the specified index |
void |
playMedia()
Plays the media loaded into the player. |
void |
playNext()
Plays the next item in the playlist |
void |
playPrevious()
Plays the previous item in the playlist |
void |
removeFromPlaylist(int index)
Removes the entry at the specified index from the players' playlist. |
void |
setAllowContextMenu(boolean allow)
Specify whether the player should display a contextual (right-click) menu when the user presses the right mouse button or the menu buttons on the skin. |
void |
setBannerEnabled(boolean enable)
Specifies whether the player should display the DivX advertisement banner at the end of playback. |
void |
setBufferingMode(DivXPlayer.BufferingMode mode)
Specify how the player should buffer downloaded data before attempting to start playback. |
void |
setControllerVisible(boolean show)
Displays or hides the player controls. |
void |
setDisplayMode(DivXPlayer.DisplayMode mode)
Specifies which skin mode the player should use to display playback controls. |
void |
setLoopCount(int loop)
Sets the number of times the current media file should repeat playback before stopping. |
void |
setPlayPosition(double position)
Sets the playback position of the current media |
void |
setPreview(java.lang.String imageURL,
java.lang.String message,
int messageFontSize)
Specifies an image, text and text size to use as a preview for the video. |
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 |
void |
setShuffleEnabled(boolean enable)
Enables or disables players' shuffle mode. |
void |
setVolume(double volume)
Sets the volume. |
void |
showLogger(boolean enable)
Displays or hides the players' logger widget. |
void |
stopMedia()
Stops the media playback. |
Methods inherited from class com.bramosystems.oss.player.core.client.AbstractMediaPlayer |
---|
addDebugHandler, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addLoadingProgressHandler, addMediaInfoHandler, addMouseDownHandler, addMouseMoveHandler, addMouseUpHandler, addPlayerStateHandler, addPlayStateHandler, addToPlayerReadyCommandQueue, fireDebug, fireError, fireLoadingProgress, fireMediaInfoAvailable, firePlayerStateEvent, firePlayStateEvent, getRate, getWidgetFactory, isPlayerOnPage, removeFromPlayerReadyCommandQueue, setConfigParameter, setConfigParameter, setConfigParameter, setRate |
Methods inherited from class com.google.gwt.user.client.ui.Composite |
---|
getWidget, initWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
addAttachHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, removeFromParent, setLayoutData, sinkEvents |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
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, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.google.gwt.event.shared.HasHandlers |
---|
fireEvent |
Constructor Detail |
---|
public DivXPlayer(java.lang.String mediaURL, boolean autoplay, java.lang.String height, java.lang.String width) throws LoadException, PluginNotFoundException, PluginVersionException
DivXPlayer
to playback media located at mediaURL
using the
default height of 90px and width of 100%. Media playback begins automatically if
autoplay
is true
.
mediaURL
- the URL of the media to playbackautoplay
- true
to play playing automatically, false
otherwiseheight
- the height of the playerwidth
- the width of the player.
LoadException
- if an error occurs while loading the media.
PluginVersionException
- if the required DivX® Web Player plugin version is not installed on the client.
PluginNotFoundException
- if DivX® Web Player plugin is not installed on the client.public DivXPlayer(java.lang.String mediaURL, boolean autoplay) throws LoadException, PluginNotFoundException, PluginVersionException
DivXPlayer
to playback media located at mediaURL
using the
default height of 90px and width of 100%. Media playback begins automatically if
autoplay
is true
.
mediaURL
- the URL of the media to playbackautoplay
- true
to play playing automatically, false
otherwise
LoadException
- if an error occurs while loading the media.
PluginVersionException
- if the required DivX® Web Player plugin version is not installed on the client.
PluginNotFoundException
- if DivX® Web Player plugin is not installed on the client.public DivXPlayer(java.lang.String mediaURL) throws LoadException, PluginNotFoundException, PluginVersionException
DivXPlayer
to automatically playback media located at
mediaURL
using the default height of 90px and width of 100%.
This is the same as calling DivXPlayer(mediaURL, true, "90px", "100%")
mediaURL
- the URL of the media to playback
LoadException
- if an error occurs while loading the media.
PluginVersionException
- if the required DivX® Web Player plugin version is not installed on the client.
PluginNotFoundException
- if DivX® Web Player plugin is not installed on the client.Method Detail |
---|
protected final void onLoad()
onLoad
in class com.google.gwt.user.client.ui.Widget
protected void onUnload()
onUnload
in class com.google.gwt.user.client.ui.Widget
public void loadMedia(java.lang.String mediaURL) throws LoadException
AbstractMediaPlayer
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.
loadMedia
in class AbstractMediaPlayer
mediaURL
- the URL of the media to load into the player.
LoadException
- if an error occurs while loading the mediapublic void playMedia() throws PlayException
AbstractMediaPlayer
playMedia
in class AbstractMediaPlayer
PlayException
- if an error occurs
during media playback.public void stopMedia()
AbstractMediaPlayer
stopMedia
in class AbstractMediaPlayer
public void pauseMedia()
AbstractMediaPlayer
pauseMedia
in class AbstractMediaPlayer
public long getMediaDuration()
AbstractMediaPlayer
getMediaDuration
in class AbstractMediaPlayer
public double getPlayPosition()
AbstractMediaPlayer
getPlayPosition
in class AbstractMediaPlayer
public void setPlayPosition(double position)
AbstractMediaPlayer
setPlayPosition
in class AbstractMediaPlayer
position
- the new position from where to start playbackpublic double getVolume()
AbstractMediaPlayer
0
(silent) to 1
(full volume).
getVolume
in class AbstractMediaPlayer
public void setVolume(double volume)
AbstractMediaPlayer
setVolume
in class AbstractMediaPlayer
volume
- 0
(silent) to 1
(full volume).public void showLogger(boolean enable)
AbstractMediaPlayer
showLogger
in class AbstractMediaPlayer
enable
- true
to make the logger widget visible, false
otherwise.Logger
public void setControllerVisible(boolean show)
If this player is not available on the panel, this method call is added to the command-queue for later execution.
setControllerVisible
in class AbstractMediaPlayer
show
- true
to make the player controls visible, false
otherwise.public boolean isControllerVisible()
isControllerVisible
in class AbstractMediaPlayer
true
if player controls are visible, false
otherwise.public int getLoopCount()
getLoopCount
in class AbstractMediaPlayer
public void setLoopCount(int loop)
If this player is not available on the panel, this method call is added to the command-queue for later execution.
setLoopCount
in class AbstractMediaPlayer
loop
- number of times to repeat playback. A negative value makes playback repeat forever!.public int getVideoHeight()
AbstractMediaPlayer
getVideoHeight
in class AbstractMediaPlayer
public int getVideoWidth()
AbstractMediaPlayer
getVideoWidth
in class AbstractMediaPlayer
public void setResizeToVideoSize(boolean resize)
AbstractMediaPlayer
setResizeToVideoSize
in class AbstractMediaPlayer
resize
- true
if player should adjust its size,
false
otherwisepublic boolean isResizeToVideoSize()
AbstractMediaPlayer
isResizeToVideoSize
in class AbstractMediaPlayer
true
if player adjusts its size, false
otherwisepublic void setBannerEnabled(boolean enable)
If this player is not available on the panel, this method call is added to the command-queue for later execution.
enable
- true
to enable, false
otherwisepublic void setAllowContextMenu(boolean allow)
If this player is not available on the panel, this method call is added to the command-queue for later execution.
allow
- true
to allow, false
otherwisepublic void setBufferingMode(DivXPlayer.BufferingMode mode)
If this player is not available on the panel, this method call is added to the command-queue for later execution.
mode
- the modepublic void setDisplayMode(DivXPlayer.DisplayMode mode)
If this player is not available on the panel, this method call is added to the command-queue for later execution.
mode
- the display modepublic DivXPlayer.DisplayMode getDisplayMode()
public void setPreview(java.lang.String imageURL, java.lang.String message, int messageFontSize)
The image file which should be in PNG, JPEG or GIF format is used as a preview
image and is displayed in place of the DivX® logo. The message
is
displayed on top of the image at the size specified by messageFontSize
.
Note: autoplay
should be set to false
for this method to
take effect.
If this player is not available on the panel, this method call is added to the command-queue for later execution.
imageURL
- the URL of the preview imagemessage
- the text displayed on top of the imagemessageFontSize
- the font size of the displayed textpublic void setShuffleEnabled(boolean enable)
PlaylistSupport
setShuffleEnabled
in interface PlaylistSupport
enable
- true
to enable shuffle, false
otherwisepublic boolean isShuffleEnabled()
PlaylistSupport
isShuffleEnabled
in interface PlaylistSupport
true
if player is in shuffle mode, false
otherwise.public void addToPlaylist(java.lang.String mediaURL)
PlaylistSupport
In respect of the same domain policy of some plugins/browsers, the URL should point to a destination on the same domain where the application is hosted.
addToPlaylist
in interface PlaylistSupport
mediaURL
- the URL of the media.public void addToPlaylist(MRL mediaLocator)
PlaylistSupport
addToPlaylist
in interface PlaylistSupport
mediaLocator
- specifies alternative URLs of the same mediapublic void addToPlaylist(java.lang.String... mediaURLs)
PlaylistSupport
The player chooses ONLY ONE of the mediaURLs
it supports.
In respect of the same domain policy of some browsers, the URLs should point to a destination on the same domain where the application is hosted.
addToPlaylist
in interface PlaylistSupport
mediaURLs
- the alternative URLs of the same media (probably in different formats).public void addToPlaylist(java.util.List<MRL> mediaLocators)
PlaylistSupport
addToPlaylist
in interface PlaylistSupport
mediaLocators
- list of alternative URLs of the same mediapublic void removeFromPlaylist(int index)
PlaylistSupport
removeFromPlaylist
in interface PlaylistSupport
index
- the index of the playlist entry.public void clearPlaylist()
PlaylistSupport
clearPlaylist
in interface PlaylistSupport
public void playNext() throws PlayException
PlaylistSupport
playNext
in interface PlaylistSupport
PlayException
- if there are no more entries in the playlist to be played. Especially if we've
advanced to the end of the playlist. Note: A player with a negative loop count (i.e. set to play
forever!) may not throw this exceptionpublic void playPrevious() throws PlayException
PlaylistSupport
playPrevious
in interface PlaylistSupport
PlayException
- if there are no more entries in the playlist to be played. Especially if we've
gotten to the beginning of the playlist. Note: A player with a negative loop count (i.e. set to play
forever!) may not throw this exceptionpublic void play(int index) throws java.lang.IndexOutOfBoundsException
PlaylistSupport
index
play
in interface PlaylistSupport
index
- number of the playlist entry
java.lang.IndexOutOfBoundsException
- if index
is outside the bounds of the playlistpublic int getPlaylistSize()
PlaylistSupport
getPlaylistSize
in interface PlaylistSupport
public RepeatMode getRepeatMode()
AbstractMediaPlayer
getRepeatMode
in class AbstractMediaPlayer
RepeatMode
public void setRepeatMode(RepeatMode mode)
AbstractMediaPlayer
The effect of the specified mode depends on the AbstractMediaPlayer.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 |
setRepeatMode
in class AbstractMediaPlayer
mode
- the new repeat modeRepeatMode
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |