Creates a hidden <audio></audio> element for simple audio playback.
createAudio() returns a new p5.MediaElement object.
The first parameter, src, is the path the audio. If a single string is passed, as in '/assets/audio.mp3', a single audio is loaded. An array of strings can be used to load the same audio in different formats. For example, ['/assets/audio.mp3', '/assets/video.wav']. This is useful for ensuring that the audio can play across different browsers with different capabilities. See MDN for more information about supported formats.
The second parameter, callback, is optional. It's a function to call once the audio is ready to play.
Examples
Syntax
createAudio([src], [callback])
Parameters
src
String|String[]: path to an audio file, or an array of paths for supporting different browsers.
callback
Function: function to call once the audio is ready to play.
Returns
p5.MediaElement: new p5.MediaElement object.
Notice any errors or typos? Please let us know. Please feel free to edit src/dom/p5.MediaElement.js and open a pull request!