dfmini player help

Hey guys, ive managed to get a dfmini mp3 module to play when triggered by a LDR, however, it only plays one second of the mp3 file loaded on it. I cant figure out how to get it to play the whole song.

The delay after the command “play” should allow the dfmini time to play the sample, however it always cuts off no matter what.

heres my code…

#include "Arduino.h"
#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

float b;

const int ledPin = 3;
const int ledpinblue = 5;
const int buzzerpin = 7;


SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

void setup()
{
  mySoftwareSerial.begin(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);
  }
  
  {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode (ledPin, OUTPUT); //red LED
pinMode (ledpinblue, OUTPUT); //blue LED
pinMode (buzzerpin, OUTPUT); //buzzer
}
  
  Serial.println(F("DFPlayer Mini online."));
  
  myDFPlayer.setTimeOut(8000); //Set serial communictaion time out 500ms
  
  //----Set volume----
  myDFPlayer.volume(30);  //Set volume value (0~30).
  
  //----Set different EQ----
  myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);

  myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);

  
  //----Read imformation----
  Serial.println(myDFPlayer.readState()); //read mp3 state
  Serial.println(myDFPlayer.readVolume()); //read current volume
  Serial.println(myDFPlayer.readEQ()); //read EQ setting
  Serial.println(myDFPlayer.readFileCounts()); //read all file counts in SD card
  Serial.println(myDFPlayer.readCurrentFileNumber()); //read current play file number
  Serial.println(myDFPlayer.readFileCountsInFolder(3)); //read file counts in folder SD:/03
}

void loop(){

b=analogRead(A5);
b=b*5/1023;

if(b>=3.0&&b<=3.45)

{delay (600);
digitalWrite(3,HIGH);

}

else{digitalWrite(3,LOW);}

if(b>=3.5&&b<4.55){delay (600);
digitalWrite(5,HIGH);

myDFPlayer.play(2);  //Play the first mp3
delay (6000); 
}
else{digitalWrite(5,LOW);}

Serial.print(" A5 ");Serial.println(b);delay(10);   
}


void printDetail(uint8_t type, int value){
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerUSBInserted:
      Serial.println("USB Inserted!");
      break;
    case DFPlayerUSBRemoved:
      Serial.println("USB Removed!");
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
  
}

any advice or guidance would be appreciated. Nice one guys!

no worries if not, just wondered if anyone has any experience with this

if(b>=3.0&&b<=3.45)

Getyourspacekeyfixed.

Your code is an absolute mess. EVERY { belongs on a line BY ITSELF. EVERY } belongs on a line BY ITSELF. And, use Tools + Auto Format to properly indent your code.

Serial.print(" A5 ");Serial.println(b);delay(10);

ONE, and only one, statement per line.

Without all the conditional crap, can you get the device to play a complete song?

You are using a library called DFRobotDFPlayerMini. Usually a library comes with working examples. You would find them in File->Examples->DFRobotDFPlayerMini->. Is there an example that will play your file? If the example stops after one second, I would guess there is something wrong with the sound file. If the example plays the file all the way through, I would guess that there is a mistake in your sketch and would recommend comparing your sketch against the example sketch.