ESPHOME Dfplayer Mini component not playing files in an expected way

Hi,

Confusingly my DfPlayer Mini is now NOT reliably playing the files I would expect it to, after I loaded some new files onto the SD card. Prior to doing this it was rock solid.

I’ve got 43 files, a mixture of wav and MP3s named like 0039.mp3 or 0001.wav.

Any ideas? Seems pretty random!

When I use the dfplayer_next (play next function) it cycles through the files exactly as they are in the folder. It’s just calling them specifically one at a time that has stopped working but which DID work prior to my updating the files in the folder. I’m kind of tempted to wipe the SD card and start again, but before I do…?

Thanks!!

Check the ESPHome device log when you try to play a file. Any errors?

Nope, no errors, and I can see the command is:

Send Command 0x3 arg 0x0d

when I ask it to play file 13…

gonna try converting all the files to MP3 AND removing the preceding ‘00’ - possible the ESPHome implementation doesn’t like that…

I’ll report back

So converting all the files to MP3 (to avoid having different file formats) and putting them in the naming schema

01.mp3
02.mp3
03.mp3

etc

hasn’t helped at all. From testing from the Home Assistant services page asking the DF player mini to

play 1 = plays 1
play 3 = plays 2
play 5 = plays 3
play 7 = plays 4
play 13 = plays 7

confused.

Ahh… might have found the answer…

The wrong file plays

I’ve read of others having the wrong files play and I got caught with this and found it very frustrating. When it has occurred, I’ve had trouble figuring out why and reproducing it until I found as others have reported that the files were playing in order they were added to the SD card and not by filename numbering.

There seems to be 4 ways to set up folders and name files:

I’ve read of others having the wrong files play and I got caught with this and found it very frustrating. When it has occurred, I’ve had trouble figuring out why and reproducing it until I found as others have reported that the files were playing in order they were added to the SD card and not by filename numbering.

There seems to be 4 ways to set up folders and name files:

  1. In folders numbered 01 – 99. File names with 3 digit prefixes 001 – 255. Command 0x0F
  2. In a folder named MP3 (or perhaps mp3). File names with 4 digit prefixes 0001 to 3000. Command 0x12
  3. In the root directory. File names with 4 digit prefixes 0001 to 3000. Command 0x03
  4. In folders named 01 – 15. File names with 4 digit prefixes 0001 – 3000. Command 0x14

While they may all appear good options, I ended up using method 1. When using method 3 the files just appear to play in the order they were added to the SD card and the digits were ignored. Methods 2 and 4 may be ok, but I found it more complicated when not using a library. Method 1 has been working well in a couple of projects for a few years. Filenames can include other characters but must have a space after the number: 001[space]filename.mp3

Yep. That was it. What an annoying situation! So I had to put all my files in a folder called ‘01’ and then change from dfplayer_play to dfplayer_play_folder and specify the file and the folder.
Anyway it seems to be working as it should, now, so that’s what matters.
Thanks @tom_l