r/ArduinoHelp • • 4d ago

Trouble playing mp3 files on aDFPlayer - Mini MP3 Player

Below is a small part of an Arduino sketch to play 3 files through a DFPlayer. The files play so everything is hooked up correctly. The problem is the files play 2 then 3 then 1. Out of order. Any idea why?

  
  myDFPlayer.volume(5);  //Set volume value. From 0 to 30 
{

myDFPlayer.play(1);  //Play the first mp3

  delay(10000);

  myDFPlayer.play(2);  //Play the second mp3

  delay(10000);

  myDFPlayer.play(3);  //Play the third mp3

}

void loop()

2 Upvotes

5 comments sorted by

1

u/imseakin 4d ago

The files are INDEXED based upon the ORDER THE FILES WERE COPIED TO THE MICROSD CARD. it is not based on their alphabetical file name.

Reformat the card and copy the files over in the order you want and you’ll see it will likely work as you expect.

I’ve fallen into that DFPlayer trap myself.

Good luck.

1

u/Idaho-Tom 4d ago

Who knew? In everything I've read it never mentioned it plays in the order loaded onto the card. Reformatted, loaded in the proper sequence and it plays correctly..

Thanks for the help.

1

u/EV-CPO 4d ago

Not always. It depends on how you name the files also. There are arcane rules posted somewhere.

1

u/EV-CPO 4d ago

Here’s what I found:

Supported Folder Structures

Numbered Folders (01 to 99): Create two-digit folders (01, 02, up to 99) in the root directory. Name files inside them with a three-digit prefix (001.mp3, 002 intro.mp3, up to 255 files per folder). Play them using folder/file commands such as playFolder(folder, file).

/mp3 Folder: Create a folder named mp3 in the root directory. Name files with a four-digit prefix (0001.mp3 to 2999.mp3 or 3000.mp3). Play them using playMp3Folder(track).

/advert Folder: Create a folder named advert in the root directory for interrupt/announcement clips. Name files with a four-digit prefix (0001.mp3, etc.).

Root Directory: Place files directly on the card without folders. The module indexes tracks by the order they are written to the file allocation table (FAT) rather than filename alone.

1

u/nixiebunny 4d ago

What OS was used to build the SD card? I had problems using a Mac because it makes extra hidden files. Also, did you copy the files in the desired order onto a freshly formatted card?