Reference createAudio()

createAudio()

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 video. If a single string is passed, as in '/assets/video.mp4', a single video is loaded. An array of strings can be used to load the same video in different formats. For example, ['/assets/video.mp4', '/assets/video.ogv', '/assets/video.webm']. This is useful for ensuring that the video 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

path to an audio file, or an array of paths for supporting different browsers.

callback

function to call once the audio is ready to play.

Notice any errors or typos? Please let us know. Please feel free to edit src/dom/dom.js and open a pull request!

Related References