com.smartgwt.client.widgets

## Class Sound

- java.lang.Object
- - com.google.gwt.user.client.ui.UIObject
  - - com.google.gwt.user.client.ui.Widget
    - - com.smartgwt.client.widgets.BaseWidget
      - - com.smartgwt.client.widgets.Sound

- 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.HasVisibility, com.google.gwt.user.client.ui.IsWidget, LogicalStructure, HasTimeChangedHandlers

      public class Sound
      extends BaseWidget
      implements HasTimeChangedHandlers

  Smart GWT class for loading and playing audio files using the HTML5 <AUDIO> element.

- - ### 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.smartgwt.client.widgets.BaseWidget

      `config, configOnly, factoryCreated, factoryProperties, id, nativeObject, scClassName`

    - ### Fields inherited from class com.google.gwt.user.client.ui.UIObject

      `DEBUG_ID_PREFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Sound()`
    `Sound(com.google.gwt.core.client.JavaScriptObject jsObj)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.gwt.event.shared.HandlerRegistration` | `addTimeChangedHandler(TimeChangedHandler handler)` Add a timeChanged handler.
    `static void` | `changeAutoChildDefaults(java.lang.String autoChildName, Canvas defaults)` Changes the defaults for Canvas AutoChildren named `autoChildName`.
    `static void` | `changeAutoChildDefaults(java.lang.String autoChildName, FormItem defaults)` Changes the defaults for FormItem AutoChildren named `autoChildName`.
    `protected com.google.gwt.core.client.JavaScriptObject` | `create()`
    `boolean` | `getAutoLoad()` Should the specified `audio file` be loaded automatically.
    `boolean` | `getAutoPlay()` Should the specified `audio file` be played automatically?
    `java.lang.Double` | `getCurrentTime()` Retrieves the current playback time of a playing or paused audio file in seconds.
    `java.lang.Double` | `getDuration()` Retrieves the duration of the current audio file in seconds.
    `com.smartgwt.logicalstructure.core.LogicalStructureObject` | `getLogicalStructure()` Getter implementing the `LogicalStructure` interface, which supports Eclipse's logical structure debugging facility.
    `static Sound` | `getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `java.lang.String` | `getSrc()` URL of the audio file to be played by this sound instance.
    `java.lang.String[]` | `getSrcAsString()` Deprecated. in favor of `getSrcAsStringArray()`.
    `java.lang.String[]` | `getSrcAsStringArray()` URL of the audio file to be played by this sound instance.
    `static boolean` | `isSupported()` Returns true for browsers which natively support HTML5 Audio, used by the Sound class
    `void` | `load()` This method will cause the `specified audio file` to be loaded
    `void` | `load(CanPlayCallback canPlayCallback)` This method will cause the `specified audio file` to be loaded
    `void` | `pause()` Pause playback of the audio file.
    `void` | `play()` Play the audio file.
    `void` | `play(PlaybackCompleteCallback callback)` Play the audio file.
    `static void` | `play(java.lang.String src)` Convenience method to load and play a specified audio file.
    `static void` | `play(java.lang.String src, PlaybackCompleteCallback callback)` Convenience method to load and play a specified audio file.
    `void` | `reset()` If playback is currently paused, reset the playback position to the start of the audio file so a call to `play()` will play from the start, rather than resuming playback from the current position.
    `Sound` | `setAutoLoad(boolean autoLoad)` Should the specified `audio file` be loaded automatically.
    `Sound` | `setAutoPlay(boolean autoPlay)` Should the specified `audio file` be played automatically?
    `void` | `setCurrentTime(java.lang.Double time)` Move playback to a particular time in a loaded audio file.
    `static void` | `setDefaultProperties(Sound soundProperties)` Class level method to set the default properties of this class.
    `com.smartgwt.logicalstructure.core.LogicalStructureObject` | `setLogicalStructure(com.smartgwt.logicalstructure.widgets.SoundLogicalStructure s)` Setter implementing the `LogicalStructure` interface, which supports Eclipse's logical structure debugging facility.
    `Sound` | `setSrc(java.lang.String... src)` URL of the audio file to be played by this sound instance.
    `Sound` | `setSrc(java.lang.String src)` URL of the audio file to be played by this sound instance.

    - ### Methods inherited from class com.smartgwt.client.widgets.BaseWidget

      `addDrawHandler, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, clearDynamicProperty, completeCreation, destroy, doAddHandler, doInit, doOnRender, draw, equals, error, errorIfNotCreated, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDateArray, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsFloatArray, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getById, getByJSObject, getClassName, getConfig, getDOM, getHandlerCount, getID, getInnerHTML, getJsObj, getOrCreateJsObj, getRef, getScClassName, getTitle, hasAutoAssignedID, hasDynamicProperty, hashCode, initNativeObject, internalSetID, internalSetID, isConfigOnly, isCreated, isDrawn, isFactoryCreated, onBind, onDestroy, onDraw, onInit, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setDefaultProperties, setDragTracker, setFactoryCreated, setHtmlElement, setID, setJavaScriptObject, setLogicalStructure, setLogicalStructure, setNullProperty, setPosition, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setScClassName, setTitle, toString`

    - ### Methods inherited from class com.google.gwt.user.client.ui.Widget

      `addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents`

    - ### 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, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, setVisible, setWidth, sinkBitlessEvent`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.google.gwt.event.shared.HasHandlers

      `fireEvent`

- - ### Constructor Detail

    - #### Sound

          public Sound()

    - #### Sound

          public Sound(com.google.gwt.core.client.JavaScriptObject jsObj)

  - ### Method Detail

    - #### getOrCreateRef

          public static Sound getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### changeAutoChildDefaults

          public static void changeAutoChildDefaults(java.lang.String autoChildName,
                                                     Canvas defaults)

      Changes the defaults for Canvas AutoChildren named `autoChildName`.
      Parameters:
        `autoChildName` - name of an AutoChild to customize the defaults for.
        `defaults` - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see `SGWTProperties`.
      See Also:
        `AutoChildUsage`

    - #### changeAutoChildDefaults

          public static void changeAutoChildDefaults(java.lang.String autoChildName,
                                                     FormItem defaults)

      Changes the defaults for FormItem AutoChildren named `autoChildName`.
      Parameters:
        `autoChildName` - name of an AutoChild to customize the defaults for.
        `defaults` - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see `SGWTProperties`.
      See Also:
        `AutoChildUsage`

    - #### create

          protected com.google.gwt.core.client.JavaScriptObject create()

      Overrides:
        `create` in class `BaseWidget`

    - #### setAutoLoad

          public Sound setAutoLoad(boolean autoLoad)

      Should the specified `audio file` be loaded automatically.

      If set to `false` developers may load the audio explicitly via `load()`

      Parameters:
        `autoLoad` - New autoLoad value. Default value is false
      Returns:
        `Sound` instance, for chaining setter calls

    - #### getAutoLoad

          public boolean getAutoLoad()

      Should the specified `audio file` be loaded automatically.

      If set to `false` developers may load the audio explicitly via `load()`

      Returns:
        Current autoLoad value. Default value is false

    - #### setAutoPlay

          public Sound setAutoPlay(boolean autoPlay)

      Should the specified `audio file` be played automatically?

      If set to `false` developers may play the audio explicitly via `play()`.

      Parameters:
        `autoPlay` - New autoPlay value. Default value is false
      Returns:
        `Sound` instance, for chaining setter calls

    - #### getAutoPlay

          public boolean getAutoPlay()

      Should the specified `audio file` be played automatically?

      If set to `false` developers may play the audio explicitly via `play()`.

      Returns:
        Current autoPlay value. Default value is false

    - #### setSrc

          public Sound setSrc(java.lang.String src)

      URL of the audio file to be played by this sound instance. If multiple file URLs are supplied, the browser will make use of the first file type for which it has support.
      If this method is called after the component has been drawn/initialized: Update the `src` of this sound instance at runtime. Note that `autoLoad` and `autoPlay` govern whether this media will be loaded or played immediately when the src value is changed.
      Parameters:
        `src` - URL of new audio file to be played by this sound instance. Default value is null
      Returns:
        `Sound` instance, for chaining setter calls

    - #### getSrc

          public java.lang.String getSrc()

      URL of the audio file to be played by this sound instance. If multiple file URLs are supplied, the browser will make use of the first file type for which it has support.
      Returns:
        Current src value. Default value is null

    - #### setSrc

          public Sound setSrc(java.lang.String... src)

      URL of the audio file to be played by this sound instance. If multiple file URLs are supplied, the browser will make use of the first file type for which it has support.
      If this method is called after the component has been drawn/initialized: Update the `src` of this sound instance at runtime. Note that `autoLoad` and `autoPlay` govern whether this media will be loaded or played immediately when the src value is changed.
      Parameters:
        `src` - URL of new audio file to be played by this sound instance. Default value is null
      Returns:
        `Sound` instance, for chaining setter calls

    - #### getSrcAsStringArray

          public java.lang.String[] getSrcAsStringArray()

      URL of the audio file to be played by this sound instance. If multiple file URLs are supplied, the browser will make use of the first file type for which it has support.
      Returns:
        Current src value. Default value is null

    - #### getCurrentTime

          public java.lang.Double getCurrentTime()

      Retrieves the current playback time of a playing or paused audio file in seconds.
      Returns:
        current playback time audio file in seconds. If the file has not been loaded, or no `src` is defined, this method will return zero.

    - #### getDuration

          public java.lang.Double getDuration()

      Retrieves the duration of the current audio file in seconds.
      Returns:
        duration of the audio file in seconds. If the file has not been loaded, or no `src` is defined, this method will return null.

    - #### load

          public void load()

      This method will cause the `specified audio file` to be loaded

    - #### load

          public void load(CanPlayCallback canPlayCallback)

      This method will cause the `specified audio file` to be loaded
      Parameters:
        `canPlayCallback` - notification to fire when the file is ready to play

    - #### pause

          public void pause()

      Pause playback of the audio file.

    - #### reset

          public void reset()

      If playback is currently paused, reset the playback position to the start of the audio file so a call to `play()` will play from the start, rather than resuming playback from the current position.

    - #### setCurrentTime

          public void setCurrentTime(java.lang.Double time)

      Move playback to a particular time in a loaded audio file.
      Parameters:
        `time` - time to move to. This method will have no effect if the file has not been loaded or no `src` element is defined.

    - #### addTimeChangedHandler

          public com.google.gwt.event.shared.HandlerRegistration addTimeChangedHandler(TimeChangedHandler handler)

      Add a timeChanged handler.

      Notification method fired repeatedly to indicate a change in currentTime value while an audio file is playing.

      Specified by:
        `addTimeChangedHandler` in interface `HasTimeChangedHandlers`
      Parameters:
        `handler` - the timeChanged handler
      Returns:
        `HandlerRegistration` used to remove this handler

    - #### isSupported

          public static boolean isSupported()

      Returns true for browsers which natively support HTML5 Audio, used by the Sound class
      Returns:
        true if Audio is supported in this browser

    - #### setDefaultProperties

          public static void setDefaultProperties(Sound soundProperties)

      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
        `soundProperties` - properties that should be used as new defaults when instances of this class are created
      See Also:
        `SGWTProperties`

    - #### play

          public void play()

      Play the audio file. If necessary the file will be loaded first.

    - #### play

          public void play(PlaybackCompleteCallback callback)

      Play the audio file. If necessary the file will be loaded first.
      Parameters:
        `playbackCompleteCallback` - notification fired when playback completes.

    - #### play

          public static void play(java.lang.String src)

      Convenience method to load and play a specified audio file.

      For more explicit control over loading and playback of audio files, developers may create an instance of Sound and call methods directly on that object.

      Parameters:
        `src` - URL of the audio clip to play.

    - #### play

          public static void play(java.lang.String src,
                                  PlaybackCompleteCallback callback)

      Convenience method to load and play a specified audio file.

      For more explicit control over loading and playback of audio files, developers may create an instance of Sound and call methods directly on that object.

      Parameters:
        `src` - URL of the audio clip to play.
        `callback` - callback to execute when the clip playback completes.

    - #### getSrcAsString

          public java.lang.String[] getSrcAsString()

      Deprecated. in favor of `getSrcAsStringArray()`.
      See `getSrcAsStringArray()`.

    - #### setLogicalStructure

          public com.smartgwt.logicalstructure.core.LogicalStructureObject setLogicalStructure(com.smartgwt.logicalstructure.widgets.SoundLogicalStructure s)

      Setter implementing the `LogicalStructure` interface, which supports Eclipse's logical structure debugging facility.

    - #### getLogicalStructure

          public com.smartgwt.logicalstructure.core.LogicalStructureObject getLogicalStructure()

      Getter implementing the `LogicalStructure` interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
        `getLogicalStructure` in interface `LogicalStructure`
      Overrides:
        `getLogicalStructure` in class `BaseWidget`