Naming A File on SD/TF Card for DF PlayerReading

In DF Player scripting

player.play(1);

is able to play the file with name 001Blood on dance the floor

but not able to play file name with prefix 011 using command

player.play(11);

or

player.play(011);

or anything like that

Also not able to play with 021 or 031 like that

What's the issue or
How to Name a file properly in actual way ??

What library are you using to control the DF Player? It depends on what command the .play() function is passing to the DF Player. It could simply be track 1 and then track 2, or it could be a prefixed track name (0000-Name.mp3) command.

O I See

I have this one

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
SoftwareSerial softwareSerial(15, 14); // RX, TX
DFRobotDFPlayerMini player;

Is this something like 0000=Name or simple 0000 Name ??

Should an extension is required there ??

Please guide , till the time I am applying track 1 2 procedure

play(2);

plays track 11

play(11);

plays track 1

Anytime any thin g is going on

I seem to recall that the track number you pass to the play function is related to the order that the files were copied onto the SD card.

If you have a file called 11.mp3 and it is the first track to be copied to the SD card, then to play it, you call play(1).

I have yet to try it out, but there is a Windows utility tool here:

This may solve the problem by reordering the entries in the File Allocation Table after you've copied all the files across to your SD card.

That library simply plays track number X which depends on the order the tracks were written to the card. It has nothing to do with the track names. A better library is DFPlayerMini_Fast which allows you to play tracks withing given folders, etc.

It is a long time since I used the DF player and at the time I wrote a few driver functions and never used any of the libraries, I seem to remember that to play a track of your choice that the track number should be hex therefore track dec 11 would be track 0xB. The libraries probably take this into account but I thought it worth a mention

Ya its exactly what is going on here . . Le me go thru this one !!

I see . . So what about rest of tracks if I go for 255 files as per limit of DF Player ??

Then you use high byte low byte

Yeah . . .I just installed DFPlayer_Fast library

So how to mention it in code as I am not getting to make the script . . please help !!!!!!!

Please have me example of some 11 files

Request

This is from the manual

2).For selections, if choose the 100th song, first convert 100 to hexadecimal, the default is double-byte, it is 0x0064. DH = 0x00; DL = 0x64

also

1).For example, select the first song played, serial transmission section: 7E FF 06 03 00 00 01 FF E6 EF

7E --- START command

FF --- Version Information

06 --- Data length (not including parity)

03 --- Representative No.

00 --- If need to acknowledge [0x01: need answering, 0x00: do not need to return the response]

00 --- Tracks high byte [DH]

01 --- Tracks low byte [DL], represented here is the first song played

FF --- Checksum high byte

E6 --- Checksum low byte

EF --- End Command

A brief example

checksum = -(Version_Byte + Command_Length + cmd + Acknowledge + arg1 + arg2)
chk_0 = checksum & 0xFF
chk_1 = (checksum >> 8) & 0xFF

This would be the transmitted string

Start_Byte, Version_Byte, Command_Length, cmd, Acknowledge,arg1, arg2, chk_1, chk_0, End_Byte

cmd would be 0x03
High byte and low byte would be arg1 and arg2

In the IDE, go to Sketch -> Include Library ->... and then select it. It will automatically insert the

#include <....>

for you. You can also go to File -> Examples ->... and select that library which comes with an example. This library is not a drop in replacement for the one you were using so you will have to make some changes.

Oh yes yes I see OK let me go thru it . . . LL update !!

nonsense. a number is just a number, you can represent it as decimal, binary, octal, or hex - whatever is more convenient.

1 Like

Yeah its detected and working and moving a step ahead in code I am having a small issue unlike previous library . . . .

With an intro of input signal as a switch to play a file I have this one with MEGA

if (digitalRead(IN22)==LOW)
  {
    player1.play(1);    
  }
  if (digitalRead(IN23)==LOW)
  {
    player1.play(2);    
  }
  if (digitalRead(IN24)==LOW)
  {
    player1.play(3);    
  }
  if (digitalRead(IN25)==LOW)
  {
    player1.play(4);    
  }
  if (digitalRead(IN26)==LOW)
  {
    player1.play(5);    
  }
  if (digitalRead(IN27)==LOW)
  {
    player1.play(6);    
  

Sometime it triggers instantly the file but not always

I have to press so many times or have to wait and then press another button to trigger another file

IN short Its not always triggering like it was doing in last case

Why is that so ??

You really want to check when a button is pressed, not if a button is being pressed.

Study the State Change Detection example in the IDE (File->examples->02.digital->State Change Detection)

Oh OK . . Le Me Go Thru @@@