Sound

Plays a sound file. The sound player uses native sound support on Internet Explorer, and falls back to using <embed> on other browsers, which means it uses QuickTime for most cases.

Availability

script.aculo.us V1.7.1 and later.

Syntax

Sound.play(soundfileUrl, [options])

Options

Option | Default | Description
track | 'global' | Name of the sound container
replace | false | If true, will stop all currently playing sounds and play the new sound. If no track is given, it will stop all sounds in 'global'

Examples

Play sound immediately in 'global' track

Sound.play('alert.mp3');

Stop playing all sounds in 'global' track and play the new sound

Sound.play('notice.mp3', {replace:true});

Place the given sound into 'chat' track, and play all sounds in 'chat'

Sound.play('info.mp3', {track:'chat'});

Stop playing all sounds in 'chat' track and play the new sound

Sound.play('error.mp3', {track:'chat', replace:true});

Notes

The recommended format to use is MP3.