Show TOC Welcome to the QLIB 1.0 Online Reference
QLIB 

QSound


Extends:QControl
Requires:
<script language="JavaScript" src="js/qlib/control.js"></script>
<script language="JavaScript" src="js/qlib/sound.js"></script>
Show Demo

Description

QSound object outputs an audio clip through wave/midi interface. This class enriches a multimedia application or game with various sound effects. The media file gets buffered when the object is created. QSound control is ready for instant playing of sound clip right after browser finishes loading all page content.

Implementation Notes

This class provides implementation only for IE 4.0 browser and its later versions. This implementation is absolutely safe and robust. Since manufactures of other browsers did not include playing sounds into the script specification, this control has no effect for them. A few browsers have multimedia extensions supported by means of various third-party plugins that are considered to be not safe for scripting and for this reason isn't covered by QLIB.

See Also

Media

Constructor

QSound(parent, name, src, volumeopt)
Creates new sound clip object and initiates media file preloading. If the sound clip is created as a child control, valid parent object must be specified. If the sound object is assigned to global variable, parent should be null. The name should be the same as the name of variable or property that has been assigned by newly created object.
Parameters
parent - Parent control (if any, null otherwise).
name - The object reference name.
src - URL of the media file.
volume - Optional output volume. Valid values range from -10000 to 0, with 0 being full wave output volume. Default is 0.

Properties

PropertyAccessDescription
volumeRReceives current output volume, that's ranged from -10000 to 0, with 0 being full wave output volume.
 
Properties inherited from QControl
nameRName of the control. Serves as a direct reference to this object when evaluated.
idRAlphanumerical unique identifier of the control.
parentRReference to the parent control (if any, null otherwise).
tagR / WCan refer any value or object, tag is always passed to all event handlers as the last parameter.
windowRThis property is a reference to JavaScript window object in which the control exists.
documentRRefers to document object in which the corresponding HTML elements exist. Normally all elements of a DOM2 compatible browser are children of the top document object. If the control creates new document scope (i.e. printing tags like <IFRAME>, <LAYER>), it should assign this document to this property.

Methods

play(loopopt)
Starts playing the clip. If the media file is missed or corrupt noting occurs.
Parameters
loop - Optional. Sets the number of times a sound clip will loop when activated. When -1 specified, the clip loops infinitely.
stop()
Stops playing of the sound clip.
setVolume(volume)
Sets current output volume, that must range from -10000 to 0, with 0 being full wave output volume.
Parameters
volume - The output volume to set.