DFPlayerMini MP3 Player My Experience

Hello. I've been working with the Arduino Uno and the DFPlayerMini for a couple years, just though I would share a bit of my experience. My application is fairly simple, 32GB SD card, 10 MP3 files in the root, and 6 Folders with about 200 MP3 files each. At this point my application and the playing of the MP3 files is working perfectly, but it was a real learning curve! My playing of the MP3 files is all software controlled, no hardware buttons. I am using the DFRobotDFPlayerMini LIBRARY to control the player.
Key to my application was being able to play the specific file I wanted, doing this with files in the ROOT of the SD Card takes some understanding!
When playing files in the ROOT of the SD Card, it doesn't matter what name you give to the files in the root, 1.mp3, 02.mp3, AAA.mp3, Joe.mp3, red.mp3. What matters, is the ORDER you COPY those files to the root of the SD Card.
The first file you copy to the SD Card ROOT, that is your file #1 , the second file you copy will be file #2, third file #3, etc. Regardless of what the actual file name is.
Copy the root files to the SD Card ONE AT A TIME, in the order you want to reference them, 1, 2, 3, 4, etc. Even if your files "look" like they are in the correct order on your hard drive, DON'T highlight several files at once and Copy / Paste them to the SD Card Root, they don't copy over in the order they appear on your hard drive (although some of them might!). Copy One file at a time.
EXAMPLE: files copied to the root of the SD Card, and the command that will play that file:
copied first: _______ Joe.mp3 _________ myDFPlayer.play(1);
copied second:____ AAA.mp3 ________ myDFPlayer.play(2);
copied third: ______ 02.mp3 __________ myDFPlayer.play(3);
copied forth: ______ 1.mp3 ___________ myDFPlayer.play(4);

The good news, it's much easier for playing files that are in FOLDERS. Simply name Folders, 01, 02 ,03 etc. and the Files in those Folders named with a three digit prefix, 001_songA.mp3, 002_old_music.mp3, 003_good_blues.mp3, etc.
With Folders, and the Files in those folders, the order you COPY them does NOT matter, Highlight / Copy and Paste them all at once. What matters here is that three digit Prefix, both the Folder and the File you want to play will be referenced by the number you assign it in the name.
EXAMPLE: files copied to Folders, and the command that will play that file:
folder: 02 ____ 005_ Joe.mp3 ______ myDFPlayer.playFolder(2, 5);
folder: 01 ____ 002_AAA.mp3 ______ myDFPlayer.playFolder(1, 2);
folder: 02 ____ 001_songA.mp3 ____ myDFPlayer.playFolder(2, 1);
folder: 01 ____ 003_bluesB.mp3 ___ myDFPlayer.playFolder(1, 3);

With the Maximum number of files per folder being 255.

3 Likes

I hope this becomes a locked topic (and my comment deleted). This is gold.

I agree that the .play() function is confusing and frustrating for beginners. As beginner, it seems like the obvious function to use, but it has that strange "file-written-order" feature that means .play(13) does not play the file 013.mp3. I also learned about this the hard way and I no longer use .play().

My solution was to use the .playMp3Folder() function. This is similar to the .playFolder() function, except that all the MP3 files should be saved into a folder called "MP3" in the root folder.

With .playFolder(), there is a limit of 255 files in each folder. With .playMp3Folder(), the limit is higher. The (poor) documentation says up to 65535 files in the MP3 folder, but the suggested file name convention of "0013.mp3" suggests a maximum of 999 9999 files. I have not needed to store such large numbers of files in projects, so haven't tested more than about 30 files in any folder.

Helpfully, you can give the files longer, more meaningful names like "0001 Oranges.mp3", "0002 Lemons.mp3" and it still works as expected (meaning .playMp3Folder(2) will play file "/MP3/0002 Lemons.mp3").

Is maximum not a 9999 files? (0001 - 9999) ?
Or the first letter of the filename must be '0' ?

Sorry, typo. I will fix.

I don't believe filenames have to start with "0", but I haven't actually tested that!

The theoretical max is 9999 but somewhere in DFR’s questionable documentation I recall seeing a ‘practical’ max recommendation of 3000. Speed declines a little at that level, but I’ve happily used up to about 3500.

I confirm that extended file names for any of the methods are ignored. After an initial numerical prefix (for obvious organisational benefit), the module is indifferent to additional characters . Ranging from ‘.MP3 to ‘-Elvis-All Shook Up_1958.mp3’ . Some of the 2800 tracks in my 26 folder JukeBox are over 30 characters long.

Even for modest numbers of files using the ‘root’ method it’s impractical to add them manually one by one. I’ve used several methods but for 100% reliabilty I now use a Powershell script, from my Win 10 PC to the mini SD card.

1 Like

After a month or two of fiddling with this DFPlayer Mini MP3 player (HW-247), all that described above I figured out by trial and error. Yeah this OP is golden. Then I hit a snag in the file naming convention and how to call it in code. Found this post.

In code, I was keeping the leading zeros and all was good until I added the "008"-th track to the folder "02", as in...

myDFPlayer.playFolder(02, 008);

...which threw following error... (Huh? What'd I miss?)

Compilation error: invalid digit "8" in octal constant

OK, well, this works then, but has the makings of a real headache...

myDFPlayer.playFolder(02, 010); //folder 02, track 008 track number in OCT = 010

Then I landed here...and, Oooooh, I get it now...DUH!

myDFPlayer.playFolder(2, 8);

Have a great day folks!

0x = hexadecimal
0b = binary
B = binary (not > 8 bits)
0 = an octal number.

Try just "8", or "10" - assuming you want to keep things 'base 10'.

Yeah, was a bit confused by the confusing documentation on this little mp3 board...about the library looking for those leading zeros in the file names and wrongly assumed that that was needed in the code.

Now if I can figure out how to incorporate the track length in the track name, have that parsed out and incorporate into appropriate delay for playing the track, from beginning to end.

Like...from file names

mp3\0001_142_ActNaturally.mp3  //  Buck Owens!!
mp3\0002_302_VietnameseBaby.mp3

...where 142 &c is track duration in seconds.

Is it because FFFF will fit into the 4.3 naming convention of the mp3 folder?

You could have a table/array with times.
You could also make use of the 'BUSY' pin.

I was just thinking of the BUSY pin cause running a millis() based Larson Scanner while playing the Knight Rider or CylonEyeSound tracks didn't work with the delay() for playing the track. I tried the .readState() funxn to facilitate the LEDs but is blocked up by the track's delay() to play.

(Sounds like I have the makings of a new post...so don't feel like I hijacking this one)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.