Better handling of eof_mp3 events: Keep playing as long as there is data remaining.

This commit is contained in:
Fabian Schlenz 2022-08-22 13:57:20 +02:00
parent fb6b5bced6
commit b9df55012f
3 changed files with 8 additions and 1 deletions

View File

@ -27,4 +27,5 @@ class Controller {
void play(); void play();
void play(String rfid_id); void play(String rfid_id);
void stop(); void stop();
void eof_mp3();
}; };

View File

@ -209,3 +209,9 @@ bool Controller::is_button_pressed(uint8_t pin) {
} }
return false; return false;
} }
void Controller::eof_mp3() {
log_d("Handling eof. Keep playing until the file is finished.");
while(audio.isRunning()) { audio.loop(); yield; }
next_track();
}

View File

@ -109,7 +109,7 @@ void audio_id3data(const char *info){ //id3 metadata
} }
void audio_eof_mp3(const char *info){ //end of file void audio_eof_mp3(const char *info){ //end of file
Serial.print("eof_mp3 ");Serial.println(info); Serial.print("eof_mp3 ");Serial.println(info);
controller.next_track(); controller.eof_mp3();
} }
void audio_showstation(const char *info){ void audio_showstation(const char *info){
Serial.print("station ");Serial.println(info); Serial.print("station ");Serial.println(info);