Class Sound
- All Implemented Interfaces:
HasAttachHandlers,HasHandlers,EventListener,HasVisibility,IsWidget,LogicalStructure,HasTimeChangedHandlers
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled -
Field Summary
Fields inherited from class com.smartgwt.client.widgets.BaseWidget
config, configOnly, factoryCreated, factoryProperties, id, nativeObject, scClassNameFields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddTimeChangedHandler(TimeChangedHandler handler) Add a timeChanged handler.static voidchangeAutoChildDefaults(String autoChildName, Canvas defaults) Changes the defaults for Canvas AutoChildren namedautoChildName.static voidchangeAutoChildDefaults(String autoChildName, FormItem defaults) Changes the defaults for FormItem AutoChildren namedautoChildName.protected JavaScriptObjectcreate()booleanShould the specifiedaudio filebe loaded automatically.booleanShould the specifiedaudio filebe played automatically?Retrieves the current playback time of a playing or paused audio file in seconds.Retrieves the duration of the current audio file in seconds.Getter implementing theLogicalStructureinterface, which supports Eclipse's logical structure debugging facility.static SoundgetOrCreateRef(JavaScriptObject jsObj) getSrc()URL of the audio file to be played by this sound instance.String[]Deprecated.String[]URL of the audio file to be played by this sound instance.static booleanReturns true for browsers which natively support HTML5 Audio, used by the Sound classvoidload()This method will cause thespecified audio fileto be loadedvoidload(CanPlayCallback canPlayCallback) This method will cause thespecified audio fileto be loadedvoidpause()Pause playback of the audio file.voidplay()Play the audio file.voidplay(PlaybackCompleteCallback callback) Play the audio file.static voidConvenience method to load and play a specified audio file.static voidplay(String src, PlaybackCompleteCallback callback) Convenience method to load and play a specified audio file.voidreset()If playback is currently paused, reset the playback position to the start of the audio file so a call toplay()will play from the start, rather than resuming playback from the current position.setAutoLoad(boolean autoLoad) Should the specifiedaudio filebe loaded automatically.setAutoPlay(boolean autoPlay) Should the specifiedaudio filebe played automatically?voidsetCurrentTime(Double time) Move playback to a particular time in a loaded audio file.static voidsetDefaultProperties(Sound soundProperties) Class level method to set the default properties of this class.Setter implementing theLogicalStructureinterface, which supports Eclipse's logical structure debugging facility.URL of the audio file to be played by this sound instance.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, 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, toStringMethods 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, unsinkEventsMethods 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, sinkBitlessEventMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Constructor Details
-
Sound
public Sound() -
Sound
-
-
Method Details
-
getOrCreateRef
-
changeAutoChildDefaults
Changes the defaults for Canvas AutoChildren namedautoChildName.- 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, seeSGWTProperties.- See Also:
-
changeAutoChildDefaults
Changes the defaults for FormItem AutoChildren namedautoChildName.- 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, seeSGWTProperties.- See Also:
-
create
- Overrides:
createin classBaseWidget
-
setAutoLoad
Should the specifiedaudio filebe loaded automatically.If set to
falsedevelopers may load the audio explicitly viaload()- Parameters:
autoLoad- New autoLoad value. Default value is false- Returns:
Soundinstance, for chaining setter calls
-
getAutoLoad
public boolean getAutoLoad()Should the specifiedaudio filebe loaded automatically.If set to
falsedevelopers may load the audio explicitly viaload()- Returns:
- Current autoLoad value. Default value is false
-
setAutoPlay
Should the specifiedaudio filebe played automatically?If set to
falsedevelopers may play the audio explicitly viaplay().- Parameters:
autoPlay- New autoPlay value. Default value is false- Returns:
Soundinstance, for chaining setter calls
-
getAutoPlay
public boolean getAutoPlay()Should the specifiedaudio filebe played automatically?If set to
falsedevelopers may play the audio explicitly viaplay().- Returns:
- Current autoPlay value. Default value is false
-
setSrc
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 thesrcof this sound instance at runtime. Note thatautoLoadandautoPlaygovern 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:
Soundinstance, for chaining setter calls
-
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
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 thesrcof this sound instance at runtime. Note thatautoLoadandautoPlaygovern 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:
Soundinstance, for chaining setter calls
-
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
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
srcis defined, this method will return zero.
-
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
srcis defined, this method will return null.
-
load
public void load()This method will cause thespecified audio fileto be loaded -
load
This method will cause thespecified audio fileto 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 toplay()will play from the start, rather than resuming playback from the current position. -
setCurrentTime
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 nosrcelement is defined.
-
addTimeChangedHandler
Add a timeChanged handler.Notification method fired repeatedly to indicate a change in currentTime value while an audio file is playing.
- Specified by:
addTimeChangedHandlerin interfaceHasTimeChangedHandlers- Parameters:
handler- the timeChanged handler- Returns:
HandlerRegistrationused 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
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:
-
play
public void play()Play the audio file. If necessary the file will be loaded first. -
play
Play the audio file. If necessary the file will be loaded first.- Parameters:
playbackCompleteCallback- notification fired when playback completes.
-
play
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
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
Deprecated.in favor ofgetSrcAsStringArray(). -
setLogicalStructure
Setter implementing theLogicalStructureinterface, which supports Eclipse's logical structure debugging facility. -
getLogicalStructure
Getter implementing theLogicalStructureinterface, which supports Eclipse's logical structure debugging facility.- Specified by:
getLogicalStructurein interfaceLogicalStructure- Overrides:
getLogicalStructurein classBaseWidget
-
getSrcAsStringArray().