   trellis.writeDisplay();
 }
 
-void playAlbumNew(byte index) {
-  switch (index) {
-    case 0: player.startPlayingFile("track001.mp3"); break;
-    case 1: player.startPlayingFile("track002.mp3"); break;
-    case 2: player.startPlayingFile("track003.mp3"); break;
-    case 3: player.sineTest(0x44, 500); break;
-  }
-}
-
-void stopPlayingAlbum() {
+boolean openNewAlbum(byte index) {
+  int albumNr = index + 1;
+  String albumTemplate = "ALBUM";
+  String albumName = albumTemplate + albumNr;
+  if (album && album.isDirectory()) album.close();
+  album = SD.open(albumName);
+}
+
+boolean playNextTrack() {
+  if (!album || !album.isDirectory()) return false;
+
+  File track = album.openNextFile();
+  if (!track) return false;
+  String albumName = album.name();
+  String dirPath = albumName + '/';
+  String filePath = dirPath + track.name();
+  Serial.print("Next track: "); Serial.println(filePath);
+  track.close();
+  
+  player.startPlayingFile(filePath.c_str());
+  return true;
+}
+
+void stopPlaying() {
   player.stopPlaying();
   delay(20);
 }

}

void onKey(byte index) {
  if (state == PLAY_SELECTED && playingAlbum == index) {
    // Pressed playing key again
    stopPlayingAlbum();
    Serial.print("Stopped album #"); Serial.println(index);
    initializeTrellis(1200);
    
    state = IDLE_LIGHT_UP;
    nextLED = 0;
  } else {
    // Pressed key to play a new album
    if (state == PLAY_SELECTED) stopPlayingAlbum();
    blinkSelected(index);
  
    playAlbumNew(index);
    Serial.print("Playing album #"); Serial.println(index);
    
    state = PLAY_SELECTED;
    playingAlbum = index;
  }
}

void onStop() {
  stopPlayingAlbum();
  Serial.print("Stopped album #"); Serial.println(playingAlbum);
  initializeTrellis(0);

  state = IDLE_LIGHT_UP;
  nextLED = 0;
}

void blinkSelected(byte index) {

    while (1);  // don't do anything more
  }
  Serial.println("SD initialized");

  File root = SD.open("/");
  while(true) {
    File entry = root.openNextFile();
    if (!entry) break;
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
    } else {
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
  }
}

void initializePlayer() {
