com.bramosystems.oss.player.core.client.ui
Class SWFWidget

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by com.bramosystems.oss.player.core.client.ui.SWFWidget
All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget

public class SWFWidget
extends com.google.gwt.user.client.ui.Composite

Widget to embed a generic Shockwave Flash application.

Usage Example

 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.
 

Since:
0.6
Author:
Sikirulai Braheem

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
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
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.
 
Method Summary
 void addProperty(String name, String value)
          Adds the property name with value value to the properties list of the Flash object.
 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()
           
 
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, onUnload, 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
 

Constructor Detail

SWFWidget

public SWFWidget(String sourceURL,
                 String width,
                 String height,
                 PluginVersion minFlashVersion)
          throws PluginNotFoundException,
                 PluginVersionException
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.

height and width are specified as CSS units.

Parameters:
sourceURL - the URL of the media to playback
height - the height of the player
width - the width of the player.
minFlashVersion - minimum version of the required Flash plugin
Throws:
PluginVersionException - 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.
See Also:
PluginVersion
Method Detail

addProperty

public void addProperty(String name,
                        String value)
Adds the property 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.

Parameters:
name - property name
value - property value

onLoad

protected void onLoad()
Overrides:
onLoad in class com.google.gwt.user.client.ui.Widget

getId

public String getId()
Returns the ID of this object. The ID is the value assigned to the id and name attributes of the generated object and embed tags.

Returns:
the ID of the object

getMissingPluginNotice

public 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. The widget provides a link to the Flash plugin download page.

Parameters:
title - the title of the message
message - descriptive message to notify user about the missing plugin
asHTML - true if message should be interpreted as HTML, false otherwise.
Returns:
missing plugin widget.
See Also:
PlayerUtil.getMissingPluginNotice(Plugin, String, String, boolean)

getMissingPluginNotice

public 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.

This is same as calling getMissingPluginNotice("Missing Plugin", "Adobe Flash Player [version] or later is required. Click here to get Flash", false)

Parameters:
version - the required Flash version
Returns:
missing plugin widget.
See Also:
getMissingPluginNotice(String, String, boolean)


Copyright © 2009-2011. All Rights Reserved.