Class R.resources.types.Sound
Extends
R.engine.PooledObject.
Represents a sound object that is abstracted from the sound system.
If the sound system does not initialize, for whatever reason, you can
still call a sound's methods.
Defined in: sound.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.resources.types.Sound(name)
|
Method Attributes | Method Name and Description |
---|---|
destroy()
Destroy the sound object
|
|
Gets the class name of this object.
|
|
Get the length of the sound, in milliseconds.
|
|
Get the position of the sound, in milliseconds, from the start of the sound.
|
|
getPan()
Get the pan of the sound, with -100 being full left and 100 being full right.
|
|
Flag to indicate if the sound ready to use.
|
|
Get the total size, in bytes, of the sound.
|
|
Get the native sound object which was created by the subclassed sound system.
|
|
Returns a boolean indicating if the sound type is supported by the browser
|
|
Get the volume the sound is playing at.
|
|
isPaused()
Returns true if the sound is currently paused.
|
|
mute()
Mute the sound (set its volume to zero).
|
|
pause()
If the sound is playing, pause the sound.
|
|
play(volume)
Play the sound.
|
|
release()
Release the sound back into the pool for reuse
|
|
resume()
If the sound is paused, it will resume playing the sound.
|
|
setPan(pan)
Set the pan of the sound, with -100 being full left and 100 being full right.
|
|
setPosition(millisecondOffset)
Set the sound offset in milliseconds.
|
|
setSoundObject(soundObj)
Set the sound object which the subclassed sound system created.
|
|
setSupportedTypeFlag(state)
Set a boolean flag indicating if the sound type is supported by the browser
|
|
setVolume(volume)
Set the volume of the sound to an integer between 0 (muted) and 100 (full volume).
|
|
stop()
If the sound is playing, stop the sound and reset it to the beginning.
|
|
unmute()
Unmute the sound (reset its volume to what it was before muting).
|
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toString, toXML
Method Detail
destroy()
Destroy the sound object
{String}
getClassName()
Gets the class name of this object.
- Returns:
- {String} The string "R.resources.types.Sound"
{Number}
getDuration()
Get the length of the sound, in milliseconds. If the sound hasn't fully loaded,
it will be the number of milliseconds currently loaded. Due to the nature of
Variable Bitrate (VBR) sounds, this number may be inaccurate.
- Returns:
- {Number} The length of the sound, in milliseconds
{Number}
getLastPosition()
Get the position of the sound, in milliseconds, from the start of the sound.
- Returns:
- {Number} The millisecond offset into the sound
{Number}
getPan()
Get the pan of the sound, with -100 being full left and 100 being full right.
- Returns:
- {Number} An integer between -100 and 100
{Boolean}
getReadyState()
Flag to indicate if the sound ready to use.
- Returns:
- {Boolean}
{Number}
getSizeBytes()
Get the total size, in bytes, of the sound. If the sound engine is not
initialized, returns 0.
- Returns:
- {Number} The size of the sound, in bytes
{Object}
getSoundObject()
Get the native sound object which was created by the subclassed sound system.
- Returns:
- {Object}
{Boolean}
getSupportedTypeFlag()
Returns a boolean indicating if the sound type is supported by the browser
- Returns:
- {Boolean}
{Number}
getVolume()
Get the volume the sound is playing at.
- Returns:
- {Number} An integer between 0 and 100
{Boolean}
isPaused()
Returns true if the sound is currently paused.
- Returns:
- {Boolean} true if the sound is paused
mute()
Mute the sound (set its volume to zero).
pause()
If the sound is playing, pause the sound.
play(volume)
Play the sound. If the volume is specified, it will set volume of the
sound before playing. If the sound was paused, it will be resumed.
- Parameters:
- volume
- {Number} [optional] An integer between 0 (muted) and 100 (full volume)
release()
Release the sound back into the pool for reuse
resume()
If the sound is paused, it will resume playing the sound.
setPan(pan)
Set the pan of the sound, with -100 being full left and 100 being full right.
- Parameters:
- pan
- {Number} An integer between -100 and 100, with 0 being center.
setPosition(millisecondOffset)
Set the sound offset in milliseconds.
- Parameters:
- millisecondOffset
- {Number} The offset into the sound to play from
setSoundObject(soundObj)
Set the sound object which the subclassed sound system created.
- Parameters:
- soundObj
- {Object} The sound's native object
setSupportedTypeFlag(state)
Set a boolean flag indicating if the sound type is supported by the browser
- Parameters:
- state
- {Boolean}
true
indicates the sound type is supported
setVolume(volume)
Set the volume of the sound to an integer between 0 (muted) and 100 (full volume).
- Parameters:
- volume
- {Number} The volume of the sound
stop()
If the sound is playing, stop the sound and reset it to the beginning.
unmute()
Unmute the sound (reset its volume to what it was before muting).