From cf433a48b28c13231151e4725e5757dc336fb928 Mon Sep 17 00:00:00 2001 From: Fabian Schlenz Date: Mon, 22 Aug 2022 08:51:19 +0200 Subject: [PATCH] Support for http(s) links in _mapping.txt --- src/controller.cpp | 10 ++++++++-- src/playlist_manager.cpp | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index a40667d..1eab3d7 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -149,8 +149,14 @@ void Controller::play(String rfid_id) { void Controller::play() { String file = current_playlist.get_current_file_name(); - Serial.printf("Playing file: %s\n", file.c_str()); - audio.connecttoFS(SD, file.c_str(), current_playlist.get_current_time()); + + if (file.startsWith("/")) { + log_i("Playing file %s via connecttoFS", file.c_str()); + audio.connecttoFS(SD, file.c_str(), current_playlist.get_current_time()); + } else if (file.startsWith("http")) { + log_i("Playing URL %s via connecttohost", file.c_str()); + audio.connecttohost(file.c_str()); + } } void Controller::next_track() { diff --git a/src/playlist_manager.cpp b/src/playlist_manager.cpp index 91ac74b..75f2776 100644 --- a/src/playlist_manager.cpp +++ b/src/playlist_manager.cpp @@ -54,6 +54,9 @@ Playlist PlaylistManager::get_playlist(String rfid_id) { entry.close(); } dir.close(); + } else if (path.startsWith("http")) { + Serial.printf("Adding URL %s to the list of files\n", path.c_str()); + current_playlist.add_file(path); } current_playlist.sort(); current_rfid_tag_id = rfid_id;