Difference between revisions of "Oolite JavaScript Reference: Sound"
(→<code>name</code>) |
|||
Line 1: | Line 1: | ||
<small>'''Prototype:''' <code>Object</code></small><br /> |
<small>'''Prototype:''' <code>Object</code></small><br /> |
||
− | <small>'''Subtypes:''' |
+ | <small>'''Subtypes:''' none |
{{Oolite-class-added|1.71}} |
{{Oolite-class-added|1.71}} |
||
− | The '''Sound''' class is used to play music or sound effects. |
||
+ | The '''Sound''' class represents sound files. A <code>Sound</code> can be played through a <code>[[Oolite JavaScript Reference: SoundSource|SoundSource]]</code>. <code>Sound</code> also provides functions to start and stop music. |
||
== Properties == |
== Properties == |
||
Line 11: | Line 11: | ||
The file name of the sound file. |
The file name of the sound file. |
||
− | == |
+ | == Static methods == |
=== <code>load</code> === |
=== <code>load</code> === |
||
function '''load'''(soundFile : String) |
function '''load'''(soundFile : String) |
||
− | Loads a music file to memory, to avoid stutter on playback. |
||
+ | Loads a sound file, and returns the resulting <code>Sound</code> object. |
||
=== <code>playMusic</code> === |
=== <code>playMusic</code> === |
||
− | function '''playMusic'''(soundFile : String) |
+ | function '''playMusic'''(soundFile : String [, loop: Boolean]) |
− | + | Play the specified music file, optionally looped. This may have no effect depending on the player’s music settings. |
|
=== <code>stopMusic</code> === |
=== <code>stopMusic</code> === |
||
function '''stopMusic'''([soundFile : String]) |
function '''stopMusic'''([soundFile : String]) |
||
− | Stops the specified sound file from playing. If no file is specified, stops all music. |
||
+ | Stop music. If a name is specified, the music will only be stopped if that’s the name of the currently playing music. For example, if you start some music with <code>Sound.playMusic("myoxp-exciting-music.ogg")</code> and later want to stop it, call <code>Sound.stopMusic("myoxp-exciting-music.ogg")</code> to avoid stopping any other music that may have taken over in the meanwhile. |
||
[[Category:Oolite scripting]] |
[[Category:Oolite scripting]] |
Revision as of 22:36, 2 October 2009
Prototype: Object
Subtypes: none
This class was added in Oolite test release 1.71.
The Sound class represents sound files. A Sound
can be played through a SoundSource
. Sound
also provides functions to start and stop music.
Properties
name
name : String (read-only)
The file name of the sound file.
Static methods
load
function load(soundFile : String)
Loads a sound file, and returns the resulting Sound
object.
playMusic
function playMusic(soundFile : String [, loop: Boolean])
Play the specified music file, optionally looped. This may have no effect depending on the player’s music settings.
stopMusic
function stopMusic([soundFile : String])
Stop music. If a name is specified, the music will only be stopped if that’s the name of the currently playing music. For example, if you start some music with Sound.playMusic("myoxp-exciting-music.ogg")
and later want to stop it, call Sound.stopMusic("myoxp-exciting-music.ogg")
to avoid stopping any other music that may have taken over in the meanwhile.