loadSound()
Loads a sound into the code's assets
Last updated
Loads a sound into the code's assets
Last updated
click the link below to play the sound.
sourceURL
web or local URL of sound to be loaded
NAME
name for variable of sound in code
Loads a sound into memory from an external source so that it can be used in code. The sourceURL can be a web address (for example "http://wow-121578.mp3") - this is the usual situation - or the local address if the file is stored with the rest of your code.
Once a sound is loaded (in the example below, using the variable 'NAME' in code), the following functions are available to call on the sound file:
assets['NAME'].play()
starts playing the sound
assets['NAME'].stop()
stops playing the sound and resets it
assets['NAME'].pause()
stops playing the sound and pauses it
assets['NAME'].isPlaying()
returns True
or False
depending on whether the sound is currently already playing
assets['NAME'].volume(V)
adjusts the volume of the sound. V is a decimal value between 0 and 1.
0 is no volume, 1 is maximum volume
Find these documents helpful? Let the people who made them help your child learn to code at Strivemath!
We'd love to hear your Feedback/Comments here.