Difference between revisions of "Oolite JavaScript Reference: Sound"

From Elite Wiki
(Moving Oolite JS reference into a subcategory of Oolite scripting.)
Line 24: Line 24:
 
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.
 
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 JavaScript reference]]
+
[[Category:Oolite JavaScript Reference]]

Revision as of 15:06, 19 June 2010

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. soundFile may be either a file name or a customsounds.plist key in square brackets.

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.