# Create playlist with p5js

**URL:** https://discourse.processing.org/t/create-playlist-with-p5js/26235
**Category:** Libraries
**Created:** [December 14, 2020, 3:05pm UTC](https://discourse.processing.org/t/create-playlist-with-p5js/26235 "2020-12-14T15:05:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ari01](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@ari01](https://discourse.processing.org/u/ari01)
#### Post date: [December 14, 2020, 3:05pm UTC](https://discourse.processing.org/t/create-playlist-with-p5js/26235/1 "2020-12-14T15:05:44Z")

</div>

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)  
> }

---

<div class="post-metadata">

### Author: ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)
#### Post date: [December 15, 2020, 2:02am UTC](https://discourse.processing.org/t/create-playlist-with-p5js/26235/2 "2020-12-15T02:02:52Z")

</div>

> **[p5.js Web Editor](https://editor.p5js.org/noelpil/sketches/w4Kb7e1W4)**
