Hello! Can someone guide me on creating a music player with p5js?
this is the code I have so far:
var files = [ ‘7rings.mp3’, ‘antisocial.mp3’, ‘badguy.mp3’, ‘badguyjb.mp3’, ‘beautifulpeople.mp3’, ‘boyfriend.mp3’, ‘crossme.mp3’, ‘goodbyes.mp3’, ‘happier.mp3’, ‘higherlove.mp3’, ‘sleep.mp3’, ‘care.mp3’, ‘lonely.mp3’, ‘haveyou.mp3’, ‘neverover.mp3’, ‘noguidance.mp3’, ‘oldtownroad.mp3’, ‘panini.mp3’, ‘pieceofheart.mp3’, ‘quepretendes.mp3’, ‘seniorita.mp3’, ‘shallow.mp3’, ‘someone.mp3’, ‘sucker.mp3’, ‘summer.mp3’, ‘sunflower.mp3’, ‘takeaway.mp3’, ‘talk.mp3’, ‘thelondon.mp3’, ‘calm.mp3’];
var i = 0;
var music_player = document.querySelector(“#music_list audio”);
function next() {
if (i === files.length - 1) {
i = 0;
} else {
i++;
}
music_player.src = files[i];
}
if (music_player === null) {
throw “Playlist Player does not exists …”;
} else {
music_player.src = files[i];
music_player.addEventListener(‘ended’, next, false)
}