Power off playlist unload.

This commit is contained in:
Blaz Kristan 2021-02-28 15:34:18 +01:00
parent a1c2c04510
commit 90808ac67e
3 changed files with 14 additions and 2 deletions

View File

@ -166,6 +166,7 @@ class PinManagerClass {
}; };
//playlist.cpp //playlist.cpp
void unloadPlaylist();
void loadPlaylist(JsonObject playlistObject); void loadPlaylist(JsonObject playlistObject);
void handlePlaylist(); void handlePlaylist();

View File

@ -30,6 +30,7 @@ void toggleOnOff()
{ {
briLast = bri; briLast = bri;
bri = 0; bri = 0;
unloadPlaylist();
} }
} }

View File

@ -74,9 +74,19 @@ void serializePlaylist() {
} }
*/ */
void unloadPlaylist() {
if (playlistEntries != nullptr) {
delete[] playlistEntries;
playlistEntries = nullptr;
}
currentPlaylist = playlistIndex = -1;
playlistLen = playlistEntryDur = 0;
}
void loadPlaylist(JsonObject playlistObj) { void loadPlaylist(JsonObject playlistObj) {
if (playlistEntries != nullptr) {delete[] playlistEntries; playlistEntries = nullptr;}
currentPlaylist = playlistIndex = -1; playlistEntryDur = 0; unloadPlaylist();
JsonArray presets = playlistObj["ps"]; JsonArray presets = playlistObj["ps"];
playlistLen = presets.size(); playlistLen = presets.size();
if (playlistLen == 0) return; if (playlistLen == 0) return;