Home Forums Sparkfun MP3 Shield Library Support Forum Setting volume when track is finishing Reply To: Setting volume when track is finishing

#1901

Very well thought out and investigated.

Not sure why your interrupts are firing like you stated. but none the less it draws out an issue. Where the added playing_state is reasonable.

I would suggest try moving the check into the void SFEMP3Shield::enableRefill() itself.

void SFEMP3Shield::enableRefill() {
 if(playing_state == playback) {
 #if defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_Timer1
 Timer1.attachInterrupt( refill );
 #elif defined(USE_MP3_REFILL_MEANS) && USE_MP3_REFILL_MEANS == USE_MP3_SimpleTimer
 timer.enable(timerId_mp3);
 #elif !defined(USE_MP3_REFILL_MEANS) || USE_MP3_REFILL_MEANS == USE_MP3_INTx
 attachInterrupt(MP3_DREQINT, refill, RISING);
 #endif
 }
}

This may be more comprehensive, as there are other locations of enableRefill(). Which are typically paired with a preceding refill(). Subsequently  ::skip()’s and “”skipTo()’s ; enableRefill() and playing_state=playback, need to be swapped.

The state-fullness of the playing brings out a whole lot of problems, such as this.