gamvas.Sound

Description

A class for sound and music files.

Constructur

new gamvas.Actor(file);

Parameters

filea JavaScript Audio class

See

gamvas.State.addSound

Example

myState = gamvas.State.extend({
    init: function() {
        this.sound = this.addSound("introsound.wav");
    },
    onKeyDown: function() {
        this.sound.play();
    }
});
Summary
gamvas.SoundA class for sound and music files.
Functions
playPlay the sound once, restarts the sound automatically
loopPlay the sound looping (e.g.
stopStops a playing sound
resumeResumes a stopped sound, without rewinding it
setRateSet the playback speed of the sound
setVolumeSet the volume of the sound
muteMute the sound
unmuteUnmute the sound
isReadyTest if the sound is ready to play

Functions

play

gamvas.Sound.prototype.play = function()

Description

Play the sound once, restarts the sound automatically

See

gamvas.Sound.stop gamvas.Sound.resume

loop

gamvas.Sound.prototype.loop = function()

Description

Play the sound looping (e.g. for background music)

See

gamvas.Sound.stop

stop

gamvas.Sound.prototype.stop = function()

Description

Stops a playing sound

See

gamvas.Sound.resume

resume

gamvas.Sound.prototype.resume = function()

Description

Resumes a stopped sound, without rewinding it

See

gamvas.Sound.stop gamvas.Sound.play

setRate

gamvas.Sound.prototype.setRate = function(r)

Description

Set the playback speed of the sound

Parameters

rthe new speed (1 = normal, < 1 = faster, > 2 = slower)

Note

Playback quality on none standard speeds differs drastically between browsers

setVolume

gamvas.Sound.prototype.setVolume = function(v)

Description

Set the volume of the sound

Parameters

vthe new volume between 0 and 1

mute

gamvas.Sound.prototype.mute = function()

Description

Mute the sound

unmute

gamvas.Sound.prototype.unmute = function()

Description

Unmute the sound

isReady

gamvas.Sound.prototype.isReady = function()

Description

Test if the sound is ready to play

Returns

true/false

gamvas.Sound.prototype.play = function()
Play the sound once, restarts the sound automatically
gamvas.Sound.prototype.loop = function()
Play the sound looping (e.g.
gamvas.Sound.prototype.stop = function()
Stops a playing sound
gamvas.Sound.prototype.resume = function()
Resumes a stopped sound, without rewinding it
gamvas.Sound.prototype.setRate = function(r)
Set the playback speed of the sound
gamvas.Sound.prototype.setVolume = function(v)
Set the volume of the sound
gamvas.Sound.prototype.mute = function()
Mute the sound
gamvas.Sound.prototype.unmute = function()
Unmute the sound
gamvas.Sound.prototype.isReady = function()
Test if the sound is ready to play
addSound: function(snd)
Add a gamvas.Sound to the state.
Close