diff --git a/README.md b/README.md index 839cfd2..2da07bb 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ I started this project back in october 2019 and never expected it to become that * Partition-layout for ESP32 is changed along with this branch. This step was necessary in order to resize (enlarge) the memory-region where especially the assignments for the RFID-tags are saved. As all permanent settings (e.g. WiFi-settings) are saved there too, it's necessary to re-enter WiFi-credentials after update. But the most important thing is to recover the assignments for the RFID-tags. Please consult my [migration-document](https://forum.espuino.de/t/wechsel-zum-refactoring-branch-was-ist-zu-beachten/510). ## Changelog Last three events: +* 28.10.2021: Added feature `SAVE_PLAYPOS_WHEN_RFID_CHANGE`. When enabled last playposition for audiobook is saved when new RFID-tag is applied. Without having this feature enabled, it's necessary to press pause first, in order to do this manually. * 27.10.2021: Added feature `SAVE_PLAYPOS_BEFORE_SHUTDOWN`. When enabled last playposition for audiobook is saved when shutdown is initiated. Without having this feature enabled, it's necessary to press pause first, in order to do this manually. * 30.09.2021: Added feature `PAUSE_WHEN_RFID_REMOVED` for RC522 after having it already for PN5180 (thanks @elmar-ops for contribution) -* 23.07.2021: Adding new playmode: from local .m3u-file (files or webstreams) ## Known bugs * Some webstreams don't run. Guess it's a combination of saturated connection-pool and lack of heap-memory. Works probably better if ESP32-WROVER (e.g. Lolin D32 pro) is used, as this chip has PSRAM. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory (and trouble). * For ESPuinos making use of SPI for SD (instead of SD_MMC), there's currently a problem that sometimes leads to incomplete file-transfers via webtransfer or FTP. I'm about to [investigate...](https://forum.espuino.de/t/probleme-beim-webtransfer/542) diff --git a/changelog.md b/changelog.md index 4380a1d..a3ca0fe 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ * 23.07.2021: Adding new playmode: from local .m3u-file (files or webstreams) * 30.09.2021: Added feature `PAUSE_WHEN_RFID_REMOVED` for RC522 after having it already for PN5180 (thanks @elmar-ops for contribution) * 27.10.2021: Added feature `SAVE_PLAYPOS_BEFORE_SHUTDOWN`. When enabled last playposition for audiobook is saved when shutdown is initiated. Without having this feature enabled, it's necessary to press pause first, in order to do this manually. +* 28.10.2021: Added feature `SAVE_PLAYPOS_WHEN_RFID_CHANGE`. When enabled last playposition for audiobook is saved when new RFID-tag is applied. Without having this feature enabled, it's necessary to press pause first, in order to do this manually. ## Old (monolithic main.cpp) * 11.07.2020: Added support for reversed Neopixel addressing. * 09.10.2020: mqttUser / mqttPassword can now be configured via webgui. diff --git a/src/AudioPlayer.cpp b/src/AudioPlayer.cpp index bf16b48..b7d4577 100644 --- a/src/AudioPlayer.cpp +++ b/src/AudioPlayer.cpp @@ -734,6 +734,15 @@ void AudioPlayer_VolumeToQueueSender(const int32_t _newVolume, bool reAdjustRota // Receives de-serialized RFID-data (from NVS) and dispatches playlists for the given // playmode to the track-queue. void AudioPlayer_TrackQueueDispatcher(const char *_itemToPlay, const uint32_t _lastPlayPos, const uint32_t _playMode, const uint16_t _trackLastPlayed) { + // Make sure last playposition for audiobook is saved when new RFID-tag is applied + #ifdef SAVE_PLAYPOS_WHEN_RFID_CHANGE + if (!gPlayProperties.pausePlay && (gPlayProperties.playMode == AUDIOBOOK || gPlayProperties.playMode == AUDIOBOOK_LOOP)) { + AudioPlayer_TrackControlToQueueSender(PAUSEPLAY); + while (!gPlayProperties.pausePlay) { // Make sure to wait until playback is paused in order to be sure that playposition saved in NVS + vTaskDelay(portTICK_RATE_MS * 100u); + } + } + #endif char *filename; filename = (char *) x_malloc(sizeof(char) * 255); @@ -761,12 +770,26 @@ void AudioPlayer_TrackQueueDispatcher(const char *_itemToPlay, const uint32_t _l if (musicFiles == NULL) { Log_Println((char *) FPSTR(errorOccured), LOGLEVEL_ERROR); System_IndicateError(); - gPlayProperties.playMode = NO_PLAYLIST; + if (!gPlayProperties.pausePlay) { + AudioPlayer_TrackControlToQueueSender(STOP); + while (!gPlayProperties.pausePlay) { + vTaskDelay(portTICK_RATE_MS * 10u); + } + } else { + gPlayProperties.playMode = NO_PLAYLIST; + } return; } else if (!strcmp(*(musicFiles - 1), "0")) { Log_Println((char *) FPSTR(noMp3FilesInDir), LOGLEVEL_NOTICE); System_IndicateError(); - gPlayProperties.playMode = NO_PLAYLIST; + if (!gPlayProperties.pausePlay) { + AudioPlayer_TrackControlToQueueSender(STOP); + while (!gPlayProperties.pausePlay) { + vTaskDelay(portTICK_RATE_MS * 10u); + } + } else { + gPlayProperties.playMode = NO_PLAYLIST; + } free(filename); return; } diff --git a/src/revision.h b/src/revision.h index f5b9cd5..2feea33 100644 --- a/src/revision.h +++ b/src/revision.h @@ -1,4 +1,4 @@ #ifndef __REVISION_H__ #define __REVISION_H__ - constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211027-1"; + constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211028-1"; #endif \ No newline at end of file