# A music player that automatically adds .wav or .mp3 files in the data folder to list?

**URL:** https://discourse.processing.org/t/a-music-player-that-automatically-adds-wav-or-mp3-files-in-the-data-folder-to-list/22473
**Category:** Libraries
**Created:** [July 8, 2020, 11:55am UTC](https://discourse.processing.org/t/a-music-player-that-automatically-adds-wav-or-mp3-files-in-the-data-folder-to-list/22473 "2020-07-08T11:55:52Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)
#### Post date: [July 8, 2020, 4:12pm UTC](https://discourse.processing.org/t/a-music-player-that-automatically-adds-wav-or-mp3-files-in-the-data-folder-to-list/22473/2 "2020-07-08T16:12:53Z")

</div>

(actually the song player is by me)

**File lister**

here is an example to register new files throughout

you have to

- select wav/mp3
- sort

Chrisir

```auto
String[] fileList=null; 

//---------------------------------------------------------------------------
// processing core functions 

void setup() {
  size(880, 800);
  background(111); // gray
}

void draw() {
  background(111); // gray
  updateList(); 
  showList();
}

//---------------------------------------------------------------------------
// Other functions 

void updateList() {
  File file = new File(dataPath(""));
  fileList = file.list();

  if (fileList==null) {
    println("Folder is empty.");
  } else {
    // success
  }//else
}//func 

void showList() {
  if (fileList==null) 
    return; // leave 

  int i=0; 
  for (String s1 : fileList) { 
    text(s1, 33, 44+i*22);
    i++;
  }//for
  //
}//func
//

```

---

_[View the full topic](https://discourse.processing.org/t/a-music-player-that-automatically-adds-wav-or-mp3-files-in-the-data-folder-to-list/22473)._
