Added playlist play endpoint (POST)
This commit is contained in:
@@ -240,6 +240,28 @@ void api_v1_playlist_create() {
|
||||
}
|
||||
}
|
||||
|
||||
void api_v1_playlist_play() {
|
||||
Serial.println("[HTTP] [API] 200 - POST '/api/v1/playlist/play'");
|
||||
|
||||
// get the right POST param
|
||||
String playlistPath;
|
||||
for (int i = 0; i < api_server.args(); i++) {
|
||||
if (api_server.argName(i) == "playlistPath") {
|
||||
playlistPath = api_server.arg(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(getSongFromPlaylist(playlistPath, 0) == "") { // if playlist is empty or nonexistent
|
||||
api_server.send(200, "application/json", generate_api_json(false)); // send no success info
|
||||
} else {
|
||||
currentPlaylist = playlistPath;
|
||||
currentPlaylistPosition = -1;
|
||||
nextAudio();
|
||||
api_server.send(200, "application/json", generate_api_json(true)); // just return the success info
|
||||
}
|
||||
}
|
||||
|
||||
void api_v1_settings_restart() {
|
||||
SD.end(); // delete SD object and sync its cache to flash
|
||||
WiFi.disconnect(); // disconnect wifi
|
||||
@@ -277,6 +299,7 @@ void setupApiWeb() {
|
||||
api_server.on("/api/v1/playback/info", HTTP_GET, api_v1_playback_info);
|
||||
api_server.on("/api/v1/playlist/get", HTTP_GET, api_v1_playlist_get);
|
||||
api_server.on("/api/v1/playlist/create", HTTP_POST, api_v1_playlist_create);
|
||||
api_server.on("/api/v1/playlist/play", HTTP_POST, api_v1_playlist_play);
|
||||
api_server.on(UriBraces("/api/v1/volume/{}"), HTTP_GET, api_v1_playback_volume);
|
||||
api_server.on("/api/v1/settings/restart", HTTP_GET, api_v1_settings_restart);
|
||||
|
||||
|
Reference in New Issue
Block a user