레퍼런스 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.

예제

구문

createAudio([src], [callback])

매개변수

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.

반환값

p5.MediaElement: new p5.MediaElement object.
This page is generated from the comments in src/dom/dom.js . Please feel free to edit it and submit a pull request!

관련 레퍼런스