YX5300 Serial MP3 Player - incorrect track played


I am playing audio on this board using MKR 1010 Serial1 port. The board was playing files from a SD card but not the correct one. There was an arbitrary offset from the intended file. I had named the files on the SD card (formatted FAT32 on Windows) as "001.mp3", "002.mp3" and so on. After several hours of checking and re-checking code and libraries I couldn't find anything obvious. Finally I went to Command Prompt on Windows and did a "DIR" command on the SD card. Turns out the board was recognizing the files in the same order as shown by the DIR command! The actual name (ex. 001) of the file did not seem to matter. So I deleted all files and copied them back to the SD card in the order of the file name (number) and all is good now.

Anyone else experienced a similar issue?

That's how the module was designed. There's documentation out there on it - usually in tutorials and (I think) the module's datasheet.

Yes, that's the way the card works. The documentation seems to imply that it plays it in the order of the names but it is definitely not the case.

I spent some time researching what was around about the module when I wrote my library. You may find additional info at https https://github.com/MajicDesigns/MD_YX5300

yes this is in the reading. it's pry playing tracks by the physical location on the card. you just need to copy them to the sd in the right order and you should be fine

correct.. naming is only a convenience (making it easier to identify)

the way you add the files to the SD card IS the order/name.

Can you guys provide me simple code to play a particular mp3 file using yx5300?

I have used the YX5300 board several times with museum projects. It is a cheap and easy to use mp3 player.

According to the datasheet/instructions there are different commands for "play first ... second ... file on SD card" and "play song with title ... in folder".

If you want to play mp3 files by name (and not by "place") you can do it like this:

Preparation of the SD card: Create a folder with name "01". This folder can hold up to 254 files. (If you need more than 254 files you can also create a folder "02", "03" and so on.)

Filenames: Filenames must start with a number (up to 255) consisting of three characters, with leading zeros. Filenames may consist of more than 3 characters, but the first three must hold the number. Examples of valid file names: 001.mp3 002_I_am_track_number_two.mp3 003 and I am the track after number 2.mp3 004 I am from Germany and use special characters like äöüß.mp3

You must not leave out a number. If there are 5 tracks in folder "01" their names must start with: 001 002 003 004 005

It is NOT OK if the names of your only 5 tracks start with: 001 024 076 099 134

How to play a specific track: According to the datasheet you can call (for example) Track 4 (004_my_super_fourth_track.mp4) in folder "01" with a command like this:

7E FF 06 0F 00 01 04 EF
Folder 01       ^
Track  04          ^

If you would like to play track number 15 in folder "01" the command would be like this:

7E FF 06 0F 00 01 0F EF

For more information regarding commands, take a look at the datasheet (link above).

I believe the DFPlayerMini_Fast.h library is compatible with the YX5300. There are examples for the library and can be installed via the Arduino IDE's Libraries Manager.

Thank you all for your responses.

The documents I referenced indicate that files on the SD card can be named “001XX.mp3”, "002XX.mp3… etc and they can be under folders “01”, “02” etc.
It led me to believe that when I try to play Track 1 on Folder 1, I could push a command code:
7E FF 06 0F 00 01 0F 01

and it would “seek” a file that starts with “001XX.mp3” and play it. But it does not do that … it simply picks the “first” file in the folder. Here “first” indicates the file saved “first” in the folder and it could as well be “003XX.mp3”. It took me a quite a while to understand this because I kept suspecting my command code.

So it’s best to not only name the files “001…”, “002…” but also “drop” or “save” files on the SD card one by one in that order. Then you are good to go.

That also means if you want to drop a new file in the middle, delete everything, rename on your desktop/ laptop and drop them again in the correct order on to the SD card.

That is correct..

Also.. NONE of this is new.. and posted over and over (and over) again in many threads here on the forum.

Bonjour tout le monde,

I just tried to name the tracks only with order number : 001 002 003 and so on, without any thing behind ! and it goes perfectly right ! So try it and write it if it works for you ? Nico

How did you ADD them to your SD card though?

THATS is what dictates the 'numbering' internally..

Keep your numbered naming convention...

and load 003 first.. then 002 ..lastly 001..

I bet they play backwards..

button #1 will play track #3 (the first one added to the SD card)