loadSound()

Loads a sound into the code's assets

Example

click the link below to play the sound.

def setup():
    ...
    loadSound("/wow-121578.mp3",'WOW')

def draw():
    ...
    assets['WOW'].play()

Syntax

def setup():
    ...
    loadSound("sourceURL",'NAME')

def draw():
    ...
    assets['NAME'].play()
    ...
    assets['NAME'].stop()

Description

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:

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.

Last updated