Adding low power features to Nano w/ 3 buttons

Hello,
I have a Nano v3, a DFRobots Mini mp3 Player, and 3 arcade buttons. The program does this: On button press, play corresponding track number on the DFplayer mini. If you press the button which corresponds to the currently playing track, stop the track. If you press the button which corresponds to a different track, stop the track and start playing the new one.

Currently a 9v battery only lasts about 2 days. I'd like to incorporate some power saving libraries or circuits and need advice on how to approach this. I'd rather do a library but don't know how to modify the code.

//This code adopted from Bounce 2 examples and DFRobotPlayer mini Examples
//Hardware is a Nano v3.0, a DFRobot DFplayerMini, and a 9V battery
// INCLUDES
#include <Bounce2.h>
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
//DEFINITIONS
#define NUM_BUTTONS 3
const uint8_t BUTTON_PINS[NUM_BUTTONS] = {5, 6, 7};
int activeButton;
Bounce * buttons = new Bounce[NUM_BUTTONS];
SoftwareSerial mySoftwareSerial(10, 11); // use digital 10 for RX, use digital 11 for TX
DFRobotDFPlayerMini myDFPlayer;

void setup() {
  mySoftwareSerial.begin(9600); //open serial communication with DFPlayer on port 9600
  Serial.begin(115200);
  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.
     Serial.println(F("Unable to begin:"));
     Serial.println(F("1.Please recheck the connection!"));
     Serial.println(F("2.Please insert the SD card!"));
    while (true);
   }
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.volume(25);
  
  for (int i = 0; i < NUM_BUTTONS; i++) {
    buttons[i].attach( BUTTON_PINS[i] , INPUT_PULLUP  );       //setup the bounce instance for the current button
    buttons[i].interval(25);              // interval in ms
  }
}

void loop() {
  bool needToToggleLed = false;
  int buttonPressed;

  for (int i = 0; i < NUM_BUTTONS; i++)  {
    buttonPressed = i+1;
    // Update the Bounce instance :
    buttons[i].update();
    // If it fell, flag the need to toggle the LED
    if ( buttons[i].fell() ) {
      needToToggleLed = true;
      if(activeButton == buttonPressed){
       myDFPlayer.stop();
        activeButton = 0;
      } else {
        activeButton = buttonPressed;
        myDFPlayer.play(buttonPressed);
      }
    }
  }

}

I'd like to incorporate some power saving libraries or circuits and need advice on how to approach this. I'd rather do a library but don't know how to modify the code.

When do you want the device to go to sleep? When do you want it to wake up.

"Save power" is a goal. It is NOT an implementable requirement.

It should wake up when any of 3 buttons is pressed, play the track and then go back to sleep. The dfplayer alllows a status check dfplayer.readstate()

vienfamily:
It should wake up when any of 3 buttons is pressed, play the track and then go back to sleep. The dfplayer alllows a status check dfplayer.readstate()

So, what have you tried? With which library? What happened?

I’ve read about the low power library, but don’t know where my main loop would go.

but don't know where my main loop would go.

Right where it is now.

In loop(), there is some event that triggers going to sleep. Test if that event has occurred, and, if it has, go to sleep (after defining/enabling the "hey, nap's over" wake up stuff).

When you wake up, you'll resume executing right after where you went to sleep, so that's where you turn the stuff back on that you need/turned off.