p5.js | setLoop() Function Last Updated : 17 Jan, 2020 Comments Improve Suggest changes Like Article Like Report The setLoop() function is an inbuilt function in p5.js library. This function is used to play the audio on the web in a loop where you can change the value when the loaded sound is playing and that will affect when it reaches the end of the current playback. Syntax: setLoop( Boolean ) Note: All the sound-related functions only work when the sound library is included in the head section of the index.html file. Parameter: This function accepts a single parameter as mentioned above and described below: Boolean: We all know that Boolean value means true or false, this parameter can the Boolean value true or false. Below given examples illustrate the p5.js setLoop() function in JavaScript: Example 1: This example will play the audio in a loop setLoop(true) is set. javascript var sound; function preload() { // Initialize sound sound = loadSound("pfivesound.mp3"); } function setup() { // Playing the preloaded sound in a loop sound.play(); sound.setLoop(true); } Example 2: This example will play the sound single time setLoop(false) is set. javascript var sound; function preload() { // Initialize sound sound = loadSound("pfivesound.mp3"); } function setup() { // Playing the preloaded sound sound.play(); sound.setLoop(false); } Online editor: https://editor.p5js.org/ Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/ Supported Browsers: The browsers supported by p5.js setLooop() function are listed below: Google Chrome Internet Explorer Firefox Safari Opera Comment More infoAdvertise with us Next Article p5.js | setLoop() Function S skyridetim Follow Improve Article Tags : JavaScript Web Technologies JavaScript-p5.js Similar Reads p5.js | stop() Function The stop() function is an inbuilt function in p5.js library. This function is used to stop the audio on the web which is playing or gonna played. After just play function if you use this function without parameter then the output will be NULL you can not hear any audio.Syntax:Â Â stop( startTime ) No 1 min read p5.js setup() Function The setup() function runs when the program starts. It is used to set the initial environment properties such as text-color, screen size, background-color and load the media file such as images and fonts. The program contains only one setup() function. The setup() function can not be called again aft 2 min read p5.js | setPath() Function The setPath() function is an inbuilt function in p5.js library. This function is used to reset the source for the SoundFile of new path. Syntax: setPath(path, callback) Note: All the sound-related functions only work when the sound library is included in the head section of the index.html file. Para 1 min read p5.js setBlue() Function The setBlue() function in p5.js is used to set the blue color value in RGB color mode. It sets the third value of the RGB format. Syntax:setBlue(blue)Parameters: The function accepts a single parameter as mentioned above and described below: blue: This parameter stores the new blue value.Example 1: 2 min read p5.js second() function The second() function in p5.js is used to return the current second of the system clock. The value of second() function lies between 0 to 59. Syntax: second() Parameters: The function does not accept any parameter. Return Value: This function returns an integer value which represents the current sec 1 min read Like