Trying to figure out why my switches dont work when midi program is playing

I have been working on a program that will send midi files that are stored on an sd card to an organ.
I have used sections of code from examples and am trying to add additional buttons.
I have made use of an example that plays all the files in order from the sd card. That part works.
But when the example is running (sending the file thru the transmitt pin) none of the other buttons will work.
to me it appears that once the playing starts a loop begins around the play function disregurading everything else .
I am really new at Arduino and the language.
If someone could head me in the right direction I would appreciate it.
The buttons are intended to allow the user to play all the files on the SD Card, or select a file and then play it or to stop the playback from either selection.
Currently, the code inside the "selectsong, playsong and stopsong" sections is there simply to show me if the buttons are responding. And they do until the playallBtn is pushed.







/*
Plays multiple midi files from an SD Card
Only midi file on the SD Card
All files must be in root directory
File names must follow following format XXXXXXXX.mid
*/
#include <SdFat.h>
#include <sdios.h>
#include <LiquidCrystal.h>
#include <MD_MIDIFile.h>
#include <avr/wdt.h>


#define SERIAL_RATE 31250  // Midi standard serial rate is 31250 baud
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

// with the arduino pin number it is connected to
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);


SDFAT SD;
File file;
File dir;
MD_MIDIFile SMF;                 // create an instance of a midi file
const byte SD_SELECT = 10;       // Chip select for Sd card is pin 10
char midiName[13];               // character array to hold midi file names
const int playallBtn = A0;        // button to play all files on sd card
const int selectsongBtn = A1;     // button to select specific song on sd card to play
const int playselectionBtn = A2;  // button to play selected song on sd card
const int stopplayBtn = A3;
const int monitorPin = A4;  // monitors the tx pin with external led

bool playFile = false;     // boolean variable indicating if a file should be played
int err;                   // error code returned from midi file load


// Variables to store switch states
int playallBtnState = 0;
int selectsongBtnState = 0;
int playselectionBtnState = 0;
int stopplayBtnState = 0;




// Called by the MIDIFile library when a file event needs to be processed
// thru the midi communications interface.
// This callback is set up in the setup() function.
void midiCallback(midi_event *pev) {
  if ((pev->data[0] >= 0x80) && (pev->data[0] <= 0xe0)) {
    Serial.write(pev->data[0] | pev->channel);
    Serial.write(&pev->data[1], pev->size - 1);
  } else {
    Serial.write(pev->data, pev->size);
    
  }
}

void setup() {
  // Set up the LCD's number of columns and rows
  lcd.begin(20, 4);     // For a 20x4 LCD (20 columns, 4 rows)
  lcd.setCursor(0, 0);  // Set cursor to column 0, row 0
  lcd.clear();
  lcd.print("MIDIMASTER By RCharles");
  lcd.setCursor(0, 2);
  lcd.print("  Please Make Your");
  lcd.setCursor(0, 3);
  lcd.print("     Selection");





  pinMode(playallBtn, INPUT_PULLUP);  // use built in pullup resistor with push button
  pinMode(selectsongBtn, INPUT_PULLUP);
  pinMode(playselectionBtn, INPUT_PULLUP);
  pinMode(stopplayBtn, INPUT_PULLUP);
  pinMode(monitorPin, LOW);  // use built in pullup resistor with push button
 pinMode(monitorPin, OUTPUT);
 digitalWrite(monitorPin, LOW);
  Serial.begin(SERIAL_RATE);

  //Initialize SD Card
  if (!SD.begin(SD_SELECT, SPI_FULL_SPEED)) {
    while (true)
      ;
  }
  // Initialize MIDIFile
  SMF.begin(&SD);
  SMF.setMidiHandler(midiCallback);
  SMF.looping(false);
}

void loop() {
  playallBtnState = digitalRead(playallBtn);
  selectsongBtnState = digitalRead(selectsongBtn);
  playselectionBtnState = digitalRead(playselectionBtn);
  stopplayBtnState = digitalRead(stopplayBtn);
  lcd.setCursor(0, 2);
  lcd.print("  Please Make Your");
  lcd.setCursor(0, 3);
  lcd.print("     Selection");

  //=============playallBtn section==========================
  // Wait for pushbutton input
  // If push button is depressed, load midi file and switch on LED
  if (playallBtnState == LOW) {
    playFile = true;
    digitalWrite(monitorPin, HIGH);  // Set the pin HIGH
delay(2000);            // Wait for the specified time
    digitalWrite(monitorPin, LOW);   // Set the pin LOW
  }
  //===================end playallBtn section================

  //====================selectsongBtn section===============


  if (selectsongBtnState == LOW) {


    digitalWrite(monitorPin, HIGH);  // Set the pin HIGH
    delay(2000);            // Wait for the specified time
    digitalWrite(monitorPin, LOW);   // Set the pin LOW
    
  }

  //================end selectsong section===================

  //================starat playselectionBtn section=============


  if (playselectionBtnState == LOW) {

 digitalWrite(monitorPin, HIGH);  // Set the pin HIGH
    delay(2000);            // Wait for the specified time
    digitalWrite(monitorPin, LOW);   // Set the pin LOW
    
   
  }





  //==============end playselectionBtn section================


  //==============begin stop playing==========================
  if (stopplayBtnState == LOW) {  //stopplaybtn on pin 6
  
    playFile = false;
    //digitalWrite(5, HIGH);  // Set the pin HIGH just ot prove button push
    //delay(2000);            // Wait for the specified time
    //digitalWrite(5, LOW);   // Set the pin LOW just to prove button push
    midi_event ev;  // Turn everything off on every channel.                
    ev.size = 0;
    ev.data[ev.size++] = 0xb0;  // All sound off
    ev.data[ev.size++] = 120;   // When All Sound Off is received all oscillators will turn off, and their volume envelopes are set to zero as soon as possible.
    ev.data[ev.size++] = 0;

    for (ev.channel = 0; ev.channel < 16; ev.channel++)
      midiCallback(&ev);
    SMF.close();
    
  }
  //=============end stop playing============================
  // play files on the SD card if playFile is true
  if (playFile == true) {
    dir.open("/");
    while (file.openNext(&dir, O_RDONLY)) {
      file.getName(midiName, 13);  // Use SdFat getfile name to get next midi file from SD Card
      file.close();

      char *nextTune = &midiName[0];  // create pointer to the filename retrieved by SdFat
      err = SMF.load(nextTune);
      lcd.setCursor(0, 1);
      lcd.print("File:");
      lcd.print(nextTune);
      lcd.setCursor(0, 2);
      //lcd.print("                    ");
      lcd.print(" Currently Playing");
      lcd.setCursor(0, 3);
      lcd.print("                    ");
//return;
      // Play until end of file is reached
      while (!SMF.isEOF()) {
        SMF.getNextEvent();
        //digitalWrite(monitorPin, HIGH);  // Switch on LED
      }
return;
      SMF.close();
      //return;
    }
  }
  // Once files are finished playing, set flag to false and switch off LED
  playFile = false;
  
 
  //wdt_enable(WDTO_30MS);  // Enable watchdog timer for 15ms
  //while (1)
  return;
  // ;  // Wait for the watchdog to reset the board
}

This part of your code blocks (nothing else happens) until you have reached the end of the file (song). Look at the MD_MIDIFile_Play.ino example that comes with the library to see how they check for EOF without using a while loop which gives them the ability to do other things.

You can also learn from this: several things at the same time

Thanks so much for heading me in the right direction! I knew something was either stopping or looping the program. Again! Thanks!