fyi … your second example is pointing to the same audio file.
Try calling onended()
for each item in the song
array in setup()
Keep track of the array index with a global variable, in your callback function play the next audio file with song[index].play()
and then check if index < song.length - 1
and either increment index
or set it to 0 depending on the evaluation.
Inside mousePressed()
you can play index 0 of the array, but you will need some further logic to stop and play the files correctly (remember setup()
contains that callback) depending on what you are going for .