Sound.setVolume
From Spheriki
Set the volume at which the sound will play.
Contents |
Usage
- sound Sphere Sound object. The sound to alter the volume of.
- volume number, from 0 to 255 inclusive. The volume to set the sound to play at.
Examples
This code will play music at a few different volumes:
var font = GetSystemFont(); function game() { var music = LoadSound("some_music.mp3"); music.play(true); Text("Music playing at normal volume."); music.setVolume(127); Text("Music playing at half volume."); music.setVolume(0); Text("Music at zero volume."); music.setVolume(63); Text("Music playing softly."); music.stop(); } function Text(t) { font.drawTextBox(0, 0, GetScreenWidth(), GetScreenHeight(), 0, t); FlipScreen(); GetKey(); }
Notes
- As shown in the demo above, Sound.setVolume can be used while the sound is playing.
- This function does not work with MIDI files.
See also
- Sphere Sound object
- LoadSound()
- Sound.getVolume()
- Sound.play()
- Sound.stop()