Added playlist getter to api
This commit is contained in:
@@ -178,6 +178,34 @@ void api_v1_playback_info() {
|
||||
api_server.send(200, "application/json", generate_api_json(true, content));
|
||||
}
|
||||
|
||||
void api_v1_playlist_get() {
|
||||
Serial.println("[HTTP] [API] 200 - GET '/api/v1/playlist/get'");
|
||||
|
||||
int index = 0;
|
||||
String content = "playlist: {";
|
||||
String currentSong;
|
||||
bool firstRun = true;
|
||||
|
||||
while(true) {
|
||||
currentSong = getSongFromPlaylist(currentPlaylist, index);
|
||||
if (currentSong == "") {
|
||||
content += "\"";
|
||||
break;
|
||||
} else if (!firstRun) {
|
||||
content += "\", ";
|
||||
}
|
||||
content += "\"" + String(index);
|
||||
content += "\": \"";
|
||||
content += currentSong;
|
||||
firstRun = false;
|
||||
|
||||
index++;
|
||||
}
|
||||
content += "}"
|
||||
|
||||
api_server.send(200, "application/json", generate_api_json(true, content));
|
||||
}
|
||||
|
||||
void api_v1_settings_restart() {
|
||||
SD.end(); // delete SD object and sync its cache to flash
|
||||
WiFi.disconnect(); // disconnect wifi
|
||||
@@ -213,6 +241,7 @@ void setupApiWeb() {
|
||||
api_server.on("/api/v1/playback/next", api_v1_playback_next);
|
||||
api_server.on("/api/v1/playback/previous", api_v1_playback_previous);
|
||||
api_server.on("/api/v1/playback/info", api_v1_playback_info);
|
||||
api_server.on("/api/v1/playlist/get", api_v1_playlist_get);
|
||||
api_server.on(UriBraces("/api/v1/volume/{}"), api_v1_playback_volume);
|
||||
api_server.on("/api/v1/settings/restart", api_v1_settings_restart);
|
||||
|
||||
|
Reference in New Issue
Block a user