The createAudio() function is used to create an audio element in the DOM. The audio is created as a p5.MediaElement, which has methods for controlling the media and its playback.
Parameters: This function accept two parameters as mentioned above and described below:
- src: It is a string or an array of strings that specified path of the audio file. The array of strings can be used to specify multiple paths for the support of various browsers.
- callback: It is a callback function that would be fired when the ‘canplaythrough’ event fires. This event is fired when the audio has completed loading and does not require any additional buffering. It is an optional parameter.
Return Value: It returns a pointer to the p5.MediaElement with the audio.
Below examples illustrate the createAudio() function in p5.js:
Online editor: https://editor.p5js.org/
- How to get the function name inside a function in PHP ?
- PHP | cos( ) Function
- D3.js | d3.map.set() Function
- p5.js | mag() Function
- PHP | sin( ) Function
- PHP | Ds\Set contains() Function
- p5.js | int() function
- PHP | each() Function
- CSS | var() Function
- PHP | ord() Function
- PHP | Ds\Set last() Function
- PHP | Ds\Set first() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.