Browse Source

Added support for fileseek

master
Torsten Stauder 4 years ago
parent
commit
1f54884c46
  1. 4
      README.md
  2. 1
      changelog.md
  3. 71
      src/main.cpp
  4. 3
      src/settings.h

4
README.md

@ -6,10 +6,10 @@
## Build status ## Build status
![build workflow](https://github.com/biologist79/ESPuino/actions/workflows/build.yml/badge.svg) ![build workflow](https://github.com/biologist79/ESPuino/actions/workflows/build.yml/badge.svg)
## Changelog ## Changelog
Moved to [another location](changelog.md) as it became to prominent here. Only last three events are kept:
* 26.02.2021: Shutdown via webgui is now available.
Moved to [another location](changelog.md). Only last three events are kept:
* 05.03.2021: Added support for remote control via infrared. Make sure to enable `IR_CONTROL_ENABLE` to use this feature and don't forget to assign corresponding rc-commands of *your* remote control to actions. * 05.03.2021: Added support for remote control via infrared. Make sure to enable `IR_CONTROL_ENABLE` to use this feature and don't forget to assign corresponding rc-commands of *your* remote control to actions.
* 19.03.2021: Added support for port-expander PCA9555. Can be used for everything, that is "button-like": buttons, headphone-detect, PN5180.IRQ. * 19.03.2021: Added support for port-expander PCA9555. Can be used for everything, that is "button-like": buttons, headphone-detect, PN5180.IRQ.
* 28.03.2021: Added support for fileseek. With commands `CMD_SEEK_FORWARDS` and `CMD_SEEK_BACKWARDS` it's possible to jump a number of seconds defined in `jumpOffset`.
## Known bugs ## 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). * 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).
* English translation/version for webgui is currently pretty outdated. This will be fixed soon when i18n-support will be integrated. * English translation/version for webgui is currently pretty outdated. This will be fixed soon when i18n-support will be integrated.

1
changelog.md

@ -33,3 +33,4 @@
* 26.02.2021: Shutdown via webgui is now available. * 26.02.2021: Shutdown via webgui is now available.
* 05.03.2021: Added support for remote control via infrared. Make sure to enable `IR_CONTROL_ENABLE` to use this feature and don't forget to assign corresponding rc-commands of *your* remote control to actions. * 05.03.2021: Added support for remote control via infrared. Make sure to enable `IR_CONTROL_ENABLE` to use this feature and don't forget to assign corresponding rc-commands of *your* remote control to actions.
* 19.03.2021: Added support for port-expander PCA9555. Can be used for everything, that is "button-like": buttons, headphone-detect, PN5180.IRQ. * 19.03.2021: Added support for port-expander PCA9555. Can be used for everything, that is "button-like": buttons, headphone-detect, PN5180.IRQ.
* 28.03.2021: Added support for fileseek. With commands `CMD_SEEK_FORWARDS` and `CMD_SEEK_BACKWARDS` it's possible to jump a number of seconds defined in `jumpOffset`.

71
src/main.cpp

@ -131,8 +131,7 @@ typedef struct { // Bit field
bool trackFinished: 1; // If current track is finished bool trackFinished: 1; // If current track is finished
bool playlistFinished: 1; // If whole playlist is finished bool playlistFinished: 1; // If whole playlist is finished
uint8_t playUntilTrackNumber: 6; // Number of tracks to play after which uC goes to sleep uint8_t playUntilTrackNumber: 6; // Number of tracks to play after which uC goes to sleep
uint8_t currentSeekmode: 2; // If seekmode is active and if yes: forward or backwards?
uint8_t lastSeekmode: 2; // Helper to determine if seekmode was changed
uint8_t seekmode: 2; // If seekmode is active and if yes: forward or backwards?
} playProps; } playProps;
playProps playProperties; playProps playProperties;
@ -1478,8 +1477,6 @@ void playAudio(void *parameter) {
playProperties.trackFinished = false; playProperties.trackFinished = false;
if (playProperties.playMode == NO_PLAYLIST) { if (playProperties.playMode == NO_PLAYLIST) {
playProperties.playlistFinished = true; playProperties.playlistFinished = true;
//playProperties.currentSeekmode = SEEK_NORMAL;
//playProperties.lastSeekmode = SEEK_NORMAL;
continue; continue;
} }
if (playProperties.saveLastPlayPosition) { // Don't save for AUDIOBOOK_LOOP because not necessary if (playProperties.saveLastPlayPosition) { // Don't save for AUDIOBOOK_LOOP because not necessary
@ -1785,25 +1782,34 @@ void playAudio(void *parameter) {
} }
} }
if (playProperties.currentSeekmode != playProperties.lastSeekmode) {
Serial.println(F("Seekmode has changed!")); // Todo
bool seekmodeChangeSuccessful = false;
if (playProperties.currentSeekmode == SEEK_NORMAL) {
seekmodeChangeSuccessful = audio.audioFileSeek(1);
} else if (playProperties.currentSeekmode == SEEK_FORWARDS) {
seekmodeChangeSuccessful = audio.audioFileSeek(4);
} else if (playProperties.currentSeekmode == SEEK_BACKWARDS) {
seekmodeChangeSuccessful = audio.audioFileSeek(-4);
}
if (seekmodeChangeSuccessful) {
playProperties.lastSeekmode = playProperties.currentSeekmode;
} else {
playProperties.currentSeekmode = playProperties.lastSeekmode;
#ifdef NEOPIXEL_ENABLE
showLedError = true;
#endif
// Handle seekmodes
if (playProperties.seekmode != SEEK_NORMAL) {
if (playProperties.seekmode == SEEK_FORWARDS) {
if (audio.setTimeOffset(jumpOffset)) {
#if (LANGUAGE == 1)
Serial.printf("%d Sekunden nach vorne gesprungen\n", jumpOffset);
#else
Serial.printf("Jumped %d seconds forwards\n", jumpOffset);
#endif
} else {
#ifdef NEOPIXEL_ENABLE
showLedError = true;
#endif
}
} else if (playProperties.seekmode == SEEK_BACKWARDS) {
if (audio.setTimeOffset(-(jumpOffset))) {
#if (LANGUAGE == 1)
Serial.printf("%d Sekunden zurueck gesprungen\n", jumpOffset);
#else
Serial.printf("Jumped %d seconds backwards\n", jumpOffset);
#endif
} else {
#ifdef NEOPIXEL_ENABLE
showLedError = true;
#endif
}
} }
playProperties.seekmode = SEEK_NORMAL;
} }
// Calculate relative position in file (for neopixel) for SD-card-mode // Calculate relative position in file (for neopixel) for SD-card-mode
@ -3235,25 +3241,11 @@ void doCmdAction(const uint16_t mod) {
break; break;
} }
case CMD_SEEK_FORWARDS: { case CMD_SEEK_FORWARDS: {
Serial.println(F("Seek forwards")); // todo
if (playProperties.currentSeekmode == SEEK_FORWARDS) {
playProperties.currentSeekmode = SEEK_NORMAL;
} else {
playProperties.currentSeekmode = SEEK_FORWARDS;
}
Serial.println(playProperties.currentSeekmode);
Serial.println(playProperties.lastSeekmode);
playProperties.seekmode = SEEK_FORWARDS;
break; break;
} }
case CMD_SEEK_BACKWARDS: { case CMD_SEEK_BACKWARDS: {
Serial.println(F("Seek backwards")); // todo
if (playProperties.currentSeekmode == SEEK_BACKWARDS) {
playProperties.currentSeekmode = SEEK_NORMAL;
} else {
playProperties.currentSeekmode = SEEK_BACKWARDS;
}
Serial.println(playProperties.currentSeekmode);
Serial.println(playProperties.lastSeekmode);
playProperties.seekmode = SEEK_BACKWARDS;
break; break;
} }
default: { default: {
@ -4664,8 +4656,7 @@ void setup() {
playProperties.pausePlay = false; playProperties.pausePlay = false;
playProperties.trackFinished = NULL; playProperties.trackFinished = NULL;
playProperties.playlistFinished = true; playProperties.playlistFinished = true;
playProperties.currentSeekmode = SEEK_NORMAL;
playProperties.lastSeekmode = SEEK_NORMAL;
playProperties.seekmode = SEEK_NORMAL;
// Examples for serialized RFID-actions that are stored in NVS // Examples for serialized RFID-actions that are stored in NVS
// #<file/folder>#<startPlayPositionInBytes>#<playmode>#<trackNumberToStartWith> // #<file/folder>#<startPlayPositionInBytes>#<playmode>#<trackNumberToStartWith>

3
src/settings.h

@ -189,6 +189,9 @@
uint16_t headphoneLastDetectionDebounce = 1000; // Debounce-interval in ms when plugging in headphone uint16_t headphoneLastDetectionDebounce = 1000; // Debounce-interval in ms when plugging in headphone
#endif #endif
// Seekmode-configuration
uint8_t jumpOffset = 30; // Offset in seconds to jump for commands CMD_SEEK_FORWARDS / CMD_SEEK_BACKWARDS
// (optional) Topics for MQTT // (optional) Topics for MQTT
#ifdef MQTT_ENABLE #ifdef MQTT_ENABLE
uint16_t mqttRetryInterval = 60; // Try to reconnect to MQTT-server every (n) seconds if connection is broken uint16_t mqttRetryInterval = 60; // Try to reconnect to MQTT-server every (n) seconds if connection is broken

Loading…
Cancel
Save