Audio can be loaded in two different ways, as follows:
loadSound()
: This preloads an entire sound into the memoryloadStream()
: This prepares the sound to be played by reading small chunks at a time to save memory
The audio.loadSound()
function loads an entire file completely into the memory and returns a reference to the audio data. Files that are loaded completely into the memory can be reused, played, and shared simultaneously on multiple channels. So, you only need to load one instance of the file. Sounds that you would use as sound effects in your game will fit in this category.
The syntax is audio.loadSound(audiofileName [, baseDir ])
.
The parameters are as follows:
audiofileName
: This specifies the name of the audio file you want to load. The supported file formats are determined by the platform the file is being run on.baseDir
: By default, sound files are expected to be in the application resources directory. If the sound file is in the application documents...