public class SWFWidget
extends com.google.gwt.user.client.ui.Composite
SimplePanel panel = new SimplePanel(); // create panel to hold the widget
Widget swf = null;
try {
// create the player
swf = new SWFWidget("www.example.com/mediafile.swf", "250px", "200px",
PluginVersion.get(8, 0, 0));
swf.addProperty("allowScriptAccess", "true"); // Note: add SWF property before adding object to panel.
swf.addProperty("flashVars", "param1=value1¶m2=value2");
} catch(PluginVersionException e) {
// catch plugin version exception and alert user to download plugin first.
// An option is to use the utility method -
getMissingPluginNotice(String, String, boolean)
swf = SWFWidget.getMissingPluginNotice("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.
swf = new HTML(".. another kind of message telling the user to download plugin..");
}
panel.setWidget(swf); // add object to panel.
Constructor and Description |
---|
SWFWidget(String sourceURL,
String width,
String height,
PluginVersion minFlashVersion)
Constructs
SWFWidget with the specified height and
width to embed Flash application located at sourceURL if the client
has a Flash plugin of version minFlashVersion or later installed. |
Modifier and Type | Method and Description |
---|---|
void |
addProperty(String name,
String value)
Adds the property
name with value value to the properties list of the
Flash object. |
void |
commitFlashVars()
Compiles the
flashVars parameter and injects it to the HTML code of this widget. |
String |
getId()
Returns the ID of this object.
|
static com.google.gwt.user.client.ui.Widget |
getMissingPluginNotice(PluginVersion version)
Convenience method to get a widget that may be used to notify the user when
the required Flash plugin is not available.
|
static com.google.gwt.user.client.ui.Widget |
getMissingPluginNotice(String title,
String message,
boolean asHTML)
Returns a widget that may be used to notify the user when the required Flash
plugin is not available.
|
protected void |
onLoad() |
void |
setFlashVar(String name,
Number value)
Adds the specified name/value parameter to
flashVars property on this widget. |
void |
setFlashVar(String name,
String value)
Adds the specified name/value parameter to
flashVars property on this widget. |
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, 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 SWFWidget(String sourceURL, String width, String height, PluginVersion minFlashVersion) throws PluginNotFoundException, PluginVersionException
SWFWidget
with the specified height
and
width
to embed Flash application located at sourceURL
if the client
has a Flash plugin of version minFlashVersion
or later installed.
height
and width
are specified as CSS units.
sourceURL
- the URL of the media to playbackheight
- the height of the playerwidth
- the width of the player.minFlashVersion
- minimum version of the required Flash pluginPluginVersionException
- if the required Flash plugin version is not installed on the client.PluginNotFoundException
- if the Flash plugin is not installed on the client.NullPointerException
- if sourceURL
, height
or width
is null.PluginVersion
public void addProperty(String name, String value)
name
with value value
to the properties list of the
Flash object.
Adding a property more than once removes previous values and only the last value is used. Also adding a null or empty value for a named property removes the property from the list if it has been added before.
The following properties are included by default and should not be used with this method:
Note: For all named properties to take effect, this method should be called before adding this widget to a panel.
name
- property namevalue
- property valueprotected void onLoad()
onLoad
in class com.google.gwt.user.client.ui.Widget
public String getId()
id
and name
attributes of the generated object and
embed tags.public static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(String title, String message, boolean asHTML)
title
- the title of the messagemessage
- descriptive message to notify user about the missing pluginasHTML
- true
if message
should be interpreted as HTML,
false
otherwise.PlayerUtil.getMissingPluginNotice(Plugin, String, String, boolean)
public static com.google.gwt.user.client.ui.Widget getMissingPluginNotice(PluginVersion version)
This is same as calling getMissingPluginNotice("Missing Plugin",
"Adobe Flash Player [version] or later is required. Click here to get Flash", false)
version
- the required Flash versiongetMissingPluginNotice(String, String, boolean)
public void setFlashVar(String name, Number value)
flashVars
property on this widget.
NB: commitFlashVars()
should be called to inject this parameter to the HTML code
name
- the name of the parametervalue
- the value of the parameter. A value null
removes the parameter from the listpublic void setFlashVar(String name, String value)
flashVars
property on this widget.
NB: commitFlashVars()
should be called to inject this parameter to the HTML code
name
- the name of the parametervalue
- the value of the parameter. A value null
removes the parameter from the listpublic void commitFlashVars()
flashVars
parameter and injects it to the HTML code of this widget.
This method should be called before adding this widget to a panel
Copyright © 2009-2013. All Rights Reserved.