Using CMD codes for DF player

Hello All,

Would any please let me know about the use of this CMD code from left side column in figure below for DF player operation ??

FOR EXAMPLE :

Suppose i want to apply this repeat function to a particular song track and the code is 0x11
(last line in diagram)

Then how to write the proper script regarding that ??

Thanks !!!!!!!!!!

What sketch do you currently have for controlling the DF player ?

Is there any particular reason you are not using one of the existing libraries for the DFPlayer? The libraries generally handle all this for you.

This type :

#include <SoftwareSerial.h>
#include "DFRobotDFPlayerMini.h"
const byte IN1 = 2;
//const int OUT1 = 5;
const byte pinDfpBusy = 12;
SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
byte pbRegister = 0;
void setup()
{  
  mySoftwareSerial.begin(9600);
  Serial.begin(9600);   // change to whatever you need/like 
  if (!myDFPlayer.begin(mySoftwareSerial)) {  //Use softwareSerial to communicate with mp3.   
    while(true){
      delay(0); // Code to compatible with ESP8266 watch dog.
    }
  }  
  myDFPlayer.volume(29);  //Set volume value. From 0 to 30
  pinMode (IN1, INPUT_PULLUP);
  //pinMode (OUT1, OUTPUT); 
}
void loop() 
{
  do
  {
    if (!digitalRead(IN1))
    {
      pbRegister = 1;    
    }      
  }while (pbRegister == 0);
   if (digitalRead(pinDfpBusy) == HIGH)
      { delay(1);
        //digitalWrite(OUT1, HIGH);
      }
   if (digitalRead(pinDfpBusy) == LOW)
        { delay(1);
        //digitalWrite(OUT1, LOW);
      }
  switch(pbRegister)
  {
    case 1:
     //Serial.println("Track 001");
     myDFPlayer.playFolder(2,1);
     break;            
  }
  pbRegister = 0;
  delay(100);
}

Ya, Please let me know any of the library for this . .

&

For now,
I have this library

"DFPlayerMini_Fast"

for pause and resume function for a song

Its working very well here . . . .

So please guide me further, as i am not able to find a proper pack !!!

Which other commands would you like to use and are you sure that they are not already supported by the library ?

The functions available can be found in DFRobotDFPlayerMini/DFRobotDFPlayerMini.h at master · DFRobot/DFRobotDFPlayerMini · GitHub

If you have that library, then looking at the github examples, you would have this line at the top of your sketch:

#include <DFPlayerMini_Fast.h>

The sketch you posted has:

#include "DFRobotDFPlayerMini.h"

I think this is the DFPlayer library that DFRobot has on their github site.

Have you looked through the library code to see if the command you want is already implemented?

Ya like with this library

"DFRobotDFPlayerMini.h"

only pause function is working but its not able to play or resume the file again

So only pause function supported, not the play function.

Now, regarding the commands, I need urgently :

stop
pause/play
loop or repeat

& if possible

then
reverse and fast forward like old cassette player.

Those commands i need . . Thanks !!!!

Do those functions make sense when used for playing MP3 files ?

Ya this one is of no use for now

#include "DFRobotDFPlayerMini.h"

as i have found a single step advance control in

#include <DFPlayerMini_Fast.h>

Now coming to the code, i hv done so many experiments with all kind of commands i know like loop resume repeat enable etc etc but a few is able to work here actually like resume pause . .

Take a look at GitHub - PowerBroker2/DFPlayerMini_Fast: Fast and easy to understand Arduino library to use the DFPlayer Mini MP3 module from DFRobot.com. This is a huge improvement (both in terms of execution speed and simplicity) to the standard library provided by DFRobot.com.

It contains a list of available functions

1 Like

Ya those are vital part of the design i am working on . .

For now i am on MP3 but finally i ll have to work on mp3 & just now i mixed mp3 and wave files together in folder and it's working very very well

:blush:

Ok Sir sure

Le me check and go thru this !!!

Thanks :blush:

What exactly do you mean by reverse and fast forward ?

Did an "old cassette player" usually have such functionality ?

Yes it was popular for that and so many musical band used to listen a tune repeatedly by reversing the tape so many times to by heart that particular tune, at the time of practice sessions to copy the music for live performance

In fact some china made cheap USB player has this kind of facility today
where you need to press long the prev. button for reverse and long press next button for fast forward

Reverse is nothing but just a bit a back on the playing track with a bit higher than normal playing speed and same with fast forward too.

Some years back old CD players had also that facility to watch a particular are from a video clip
We did it for "Matrix trilogy" and "Transformer" movies so many time :joy: :joy: :joy: :joy:

Even old VHS has this facility of rewind and fast forward

indexfgnhjkjhkmtghg

5Th and 6th number icon in image above !!!!!!

Cassette

Uploading: cassette-tape-controls-53351.jpg...

cgbhfgh

Some times fast forward are labelled cue as per operation mechanized withing the playing unit

As the list of CMD codes that you posted does not include fast forward and rewind then it is unlikely that a library would support them don't you think ?

No issues . .

So i wrote, "if possible" :blush:

Imp things are

play/pause
stop
loop or repeat (a particular track)

That's it !!

One issue is here :

While pressing the key assigned with loop command, it starts playing the song or file from very beginning again :unamused: disturbing the flow

This function is unlike the SD card module with those TMRpcm spi sd and all that things.
In that case,
While playing a song you can get any real time playing song inside a loop system without disturbing the continuity of that song where, the module smoothly play the song and after getting stopped it starts playing again and this looping process continues until the loop button get pressed again . .

Just last night i did the practical and its done.

How to overcome this ?

What happens if you use the library startRepeatPlay() function instead of the library loop() function ?

Does it cause the current song to restart immediately ?

Yes Yes Yes with loop function only the current song restarts immediately from beginning !!!!

Well,

Some Observations after practicals below :

  1. pause and play separately is supported by both the library

    DFRobotDFPlayerMini
    &
    DFPlayerMini_Fast

  2. resume is member of
    DFPlayerMini_Fast
    but
    not the start

  3. start is member of
    DFRobotDFPlayerMini
    but
    not the resume

  4. loop(1) detects & starts the song 001 from beginning
    loop(3) detects & starts the song 003 from beginning
    and so on . . . . . . . .

    to get it under looping conditions for playing !!!!

  5. Unlike SD Card Module, the pause /play with single button is not supported by any of these
    currently implemented library.

    Don't know if its somewhere else present