Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug 76: handleNext method of active modifier is not called twice anymore if a duplicate OnPlayFinished event is received #77

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions Tonuino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ folderSettings *myFolder;
unsigned long sleepAtMillis = 0;
static uint16_t _lastTrackFinished;

static void nextTrack(uint16_t track);
static void nextTrack();
uint8_t voiceMenu(int numberOfOptions, int startMessage, int messageOffset,
bool preview = false, int previewFromFolder = 0, int defaultValue = 0, bool exitWithLongPress = false);
bool isPlaying();
Expand Down Expand Up @@ -98,10 +98,16 @@ class Mp3Notify {
Serial.println(action);
}
static void OnPlayFinished(DfMp3_PlaySources source, uint16_t track) {
// Serial.print("Track beendet");
// Serial.println(track);
Serial.print("Track beendet ");
Serial.println(track);
// delay(100);
nextTrack(track);
if (track == _lastTrackFinished) {
Serial.println(F("Ignoring duplicate OnPlayFinished event"));
return;
}

_lastTrackFinished = track;
nextTrack();
}
static void OnPlaySourceOnline(DfMp3_PlaySources source) {
PrintlnSourceAction(source, "online");
Expand Down Expand Up @@ -511,17 +517,11 @@ class FeedbackModifier: public Modifier {
};

// Leider kann das Modul selbst keine Queue abspielen, daher müssen wir selbst die Queue verwalten
static void nextTrack(uint16_t track) {
Serial.println(track);
static void nextTrack() {
if (activeModifier != NULL)
if (activeModifier->handleNext() == true)
return;

if (track == _lastTrackFinished) {
return;
}
_lastTrackFinished = track;

if (knownCard == false)
// Wenn eine neue Karte angelernt wird soll das Ende eines Tracks nicht
// verarbeitet werden
Expand Down Expand Up @@ -835,7 +835,7 @@ void nextButton() {
if (activeModifier->handleNextButton() == true)
return;

nextTrack(random(65536));
nextTrack();
delay(1000);
}

Expand Down