It's working more or less...

This commit is contained in:
2022-08-21 11:37:42 +02:00
parent 978b25c34d
commit 9c31f70c57
9 changed files with 281 additions and 35 deletions

View File

@@ -64,18 +64,18 @@ Playlist PlaylistManager::get_playlist(String rfid_id) {
Serial.printf("No known playlist for id %s.\n", rfid_id);
return current_playlist;
} else {
current_playlist = Playlist();
String entry = map[rfid_id];
if (entry.startsWith("/")) {
File dir = SD.open(entry);
current_playlist = Playlist(rfid_id);
String path = map[rfid_id];
if (path.startsWith("/")) {
File dir = SD.open(path);
while(File entry = dir.openNextFile()) {
String filename = entry.name();
String ext = filename.substring(filename.length()-4);
if (!entry.isDirectory() &&
!filename.startsWith(".") &&
ext.equals(".mp3")) {
Serial.printf("Adding %s to the list of files\n", filename);
current_playlist.add_file(filename);
Serial.printf("Adding %s to the list of files\n", (path + "/" + filename).c_str());
current_playlist.add_file(path + "/" + filename);
}
entry.close();
}
@@ -90,4 +90,8 @@ Playlist PlaylistManager::get_playlist(String rfid_id) {
void PlaylistManager::set_audio_current_time(uint32_t time) {
audio_current_time = time;
}
bool PlaylistManager::has_playlist(String rfid_id) {
return map.count(rfid_id) == 1;
}