|
||||||||||
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.youtube.client.YouTubePlayer
public class YouTubePlayer
Widget to embed YouTube video
SimplePanel panel = new SimplePanel(); // create panel to hold the player
Widget player = null;
try {
// create the player
player = new YouTubePlayer("http://www.youtube.com/v/VIDEO_ID&fs=1", "100%", "350px");
} 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(e.getPlugin());
} 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 |
---|
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 | |
---|---|
protected java.lang.String |
_height
|
protected java.lang.String |
_vURL
|
protected java.lang.String |
_width
|
protected com.bramosystems.oss.player.youtube.client.impl.YouTubePlayerImpl |
impl
|
protected java.lang.String |
playerId
|
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Constructor Summary | |
---|---|
YouTubePlayer(java.lang.String videoURL,
PlayerParameters playerParameters,
java.lang.String width,
java.lang.String height)
Constructs YouTubePlayer with the specified height and
width to playback video located at videoURL using the specified
playerParameters |
|
YouTubePlayer(java.lang.String videoURL,
java.lang.String width,
java.lang.String height)
Constructs YouTubePlayer with the specified height and
width to playback video located at videoURL |
Method Summary | ||
---|---|---|
com.google.gwt.event.shared.HandlerRegistration |
addPlaybackQualityChangeHandler(PlaybackQualityChangeHandler handler)
Adds a PlaybackQualityChangeHandler handler to the player |
|
java.util.ArrayList<PlaybackQuality> |
getAvailableQualityLevels()
Returns the list of quality formats in which the current video is available. |
|
int |
getLoopCount()
Returns the number of times this player repeats playback before stopping. |
|
long |
getMediaDuration()
Returns the duration of the loaded media in milliseconds. |
|
protected java.lang.String |
getNormalizedVideoAppURL(java.lang.String videoURL,
PlayerParameters playerParameters)
Returns the normalized URL of the video. |
|
PlaybackQuality |
getPlaybackQuality()
Retrieves the playback quality of the current video. |
|
double |
getPlayPosition()
Gets the current position in the media that is being played. |
|
RepeatMode |
getRepeatMode()
Returns the current playback repeat mode |
|
double |
getVolume()
Gets the volume ranging from 0 (silent) to 1 (full volume). |
|
boolean |
isControllerVisible()
Checks whether the player controls are visible. |
|
void |
loadMedia(java.lang.String mediaURL)
Loads the media at the specified URL into the player. |
|
protected void |
onLoad()
|
|
protected void |
onUnload()
|
|
protected java.lang.String |
paramsToString(PlayerParameters playerParameters)
Converts the PlayerParameters object into YouTube™ video URL parameters. |
|
protected void |
parseURLParams(java.lang.String videoURL,
PlayerParameters playerParameters)
Puts all URL parameters that may be present in the videoURL into the
playerParameters object. |
|
void |
pauseMedia()
Pause the media playback |
|
protected void |
playerInit()
Called when player initialization is completed. |
|
void |
playMedia()
Plays the media loaded into the player. |
|
|
setConfigParameter(ConfigParameter param,
T value)
Sets the specified player parameter to the specified value IF AND ONLY IF the parameter is applicable on the player |
|
void |
setLoopCount(int loop)
Sets the number of times the current media file should repeat playback before stopping. |
|
void |
setPlaybackQuality(PlaybackQuality suggestedQuality)
Sets the suggested video quality for the current video. |
|
void |
setPlayPosition(double position)
Sets the playback position of the current media |
|
void |
setRepeatMode(RepeatMode mode)
Puts the player in the specified repeat mode. |
|
void |
setVolume(double volume)
Sets the volume. |
|
void |
showLogger(boolean show)
Displays or hides the players' logger widget. |
|
void |
stopMedia()
Stops the media playback. |
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 |
Field Detail |
---|
protected com.bramosystems.oss.player.youtube.client.impl.YouTubePlayerImpl impl
protected java.lang.String playerId
protected java.lang.String _width
protected java.lang.String _height
protected java.lang.String _vURL
Constructor Detail |
---|
public YouTubePlayer(java.lang.String videoURL, java.lang.String width, java.lang.String height) throws PluginNotFoundException, PluginVersionException
YouTubePlayer
with the specified height
and
width
to playback video located at videoURL
height
and width
are specified as CSS units.
videoURL
- the URL of the videowidth
- the width of the playerheight
- the height of the player
PluginNotFoundException
- if the required Flash player plugin is not found
PluginVersionException
- if Flash player version 8 and above is not found
java.lang.NullPointerException
- if either videoURL
, height
or width
is nullpublic YouTubePlayer(java.lang.String videoURL, PlayerParameters playerParameters, java.lang.String width, java.lang.String height) throws PluginNotFoundException, PluginVersionException
YouTubePlayer
with the specified height
and
width
to playback video located at videoURL
using the specified
playerParameters
height
and width
are specified as CSS units.
videoURL
- the URL of the videoplayerParameters
- the parameters of the playerwidth
- the width of the playerheight
- the height of the player
PluginNotFoundException
- if the required Flash player plugin is not found
PluginVersionException
- if Flash player version 8 and above is not found
java.lang.NullPointerException
- if either videoURL
, height
or width
is nullMethod Detail |
---|
protected 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
protected java.lang.String getNormalizedVideoAppURL(java.lang.String videoURL, PlayerParameters playerParameters)
This method is called by the player Constructors. It adjusts the parameters that may
be present in the videoURL
and playerParameters
(possibly overriding some)
to match the requirements of this players' internals.
videoURL
- the URL of the YouTube™ videoplayerParameters
- the parameters of the video
protected void playerInit()
protected final void parseURLParams(java.lang.String videoURL, PlayerParameters playerParameters)
videoURL
into the
playerParameters
object.
Note: when this method returns, all parameters present in videoURL
would have been
removed. For example:
If videoURL
before method call is http://www.youtube.com/v/VIDEO_ID¶mName=value,
then videoURL
after method call is http://www.youtube.com/v/VIDEO_ID.
videoURL
- the URL of the YouTube™ videoplayerParameters
- the parameters of the videoprotected final java.lang.String paramsToString(PlayerParameters playerParameters)
playerParameters
- the player parameters
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 int getLoopCount()
AbstractMediaPlayer
0
, subclasses should override and implement
accordingly.
getLoopCount
in class AbstractMediaPlayer
public void setLoopCount(int loop)
AbstractMediaPlayer
NB: As of version 1.2, the behaviour of this property depends on
the AbstractMediaPlayer.setRepeatMode(RepeatMode)
property
setLoopCount
in class AbstractMediaPlayer
loop
- number of times to repeat playback. A negative value makes playback repeat forever!.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
public boolean isControllerVisible()
isControllerVisible
in class AbstractMediaPlayer
true
if player controls are visible, false
otherwise.public void showLogger(boolean show)
AbstractMediaPlayer
showLogger
in class AbstractMediaPlayer
show
- true
to make the logger widget visible, false
otherwise.Logger
public void setPlaybackQuality(PlaybackQuality suggestedQuality)
Note: Calling this method does not guarantee that the playback quality will actually change. If the playback quality does change, it will only change for the video being played and the PlaybackQualityChangeEvent event will be fired.
If suggestedQuality
is not available for the current video, then the quality will be
set to the next lowest level that is available. That is, if suggestedQuality
is
PlaybackQuality.hd720 and that is unavailable, then the playback quality will be
set to PlaybackQuality.large if that quality level is available.
suggestedQuality
- the suggested video quality for the current videopublic PlaybackQuality getPlaybackQuality() throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if no video is loaded in the playerpublic java.util.ArrayList<PlaybackQuality> getAvailableQualityLevels()
An empty list is returned if no video is loaded.
public com.google.gwt.event.shared.HandlerRegistration addPlaybackQualityChangeHandler(PlaybackQualityChangeHandler handler)
PlaybackQualityChangeHandler
handler to the player
handler
- handler for the PlaybackQualityChangeEvent event
HandlerRegistration
used to remove the handlerpublic <T extends ConfigValue> void setConfigParameter(ConfigParameter param, T value)
AbstractMediaPlayer
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.
setConfigParameter
in class AbstractMediaPlayer
T
- the paramter value typeparam
- the configuration parametervalue
- the parameter value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |