Fixed advent mode and persistence stuff.

This commit is contained in:
2019-11-29 21:20:19 +01:00
parent 4eef69516e
commit 51bef05465
3 changed files with 48 additions and 35 deletions

View File

@ -317,12 +317,19 @@ void Playlist::shuffle(uint8_t random_offset) {
}
void Playlist::advent_shuffle(uint8_t day) {
if (day > 24) day = 24;
TRACE("advent_shuffle running...\n");
// Not enough songs till the current day? Play all songs in the default order.
if (day > _files.size()) {
return;
}
// We are in the "different playlist every day" mode. So we don't persist it in order to not miss changes.
persistence = PERSIST_NONE;
if (day > _files.size()) return;
_files.insert(_files.begin(), _files[day - 1]);
_files.erase(_files.begin() + day - 1, _files.end());
_files.erase(_files.begin() + day, _files.end());
}
void Playlist::reset() {