Playing multiple songs in row

thank you so much ithink its working now

let song = [];
let index= 0;
function setup() {
  song[0] = loadSound('sample1.mp3');
  song[1] = loadSound('sample2.mp3');
  song[2] = loadSound("sample3.mp3");
  song[3] = loadSound("sample4.mp3");
  
  createCanvas(720, 200);
  background(255, 0, 0);
}
function draw(){
song.forEach(sound => {
  sound.onended(go)
});

function go(){
  if( index < song.length-1  ){
  song[index+1].play()
  index++
  }
}
 
}
function mousePressed() {
  song[0].play()
  index = 0
}
1 Like