Play the same song repeatedly with DF Mini player?

How do I make it possible to play the same song repeatedly with DF Mini player according to the code below this text? Or is it possible?

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial softwareSerial(10,11);
DFRobotDFPlayerMini myPlayer;

void setup()
{
   softwareSerial.begin(9600);
}

void loop()
{
    softwareSerial.begin(9600);
    myPlayer.begin(softwareSerial); 
    myPlayer.volume(25);
    myPlayer.play(1);
    delay(30000);
}

Consider the following:

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial softwareSerial(10,11);
DFRobotDFPlayerMini myPlayer;

void setup()
{
    softwareSerial.begin(9600);
    myPlayer.begin(softwareSerial); 
    myPlayer.volume(25);
    myPlayer.loop(1);
}

void loop()
{
}

The software serial port is initialized once. The DFPlayer is initialized once. The volume is set once. Then the first track is set up to loop forever. Finally, the processor executes an empty loop.

IIRC, you can do this without the arduino. If you only have one song loaded, Mini Player will repeat it as long as the Play input is active.

You've got to know that this is going to need "revision".

  1. Save renamed copies of your one audio file until the SD card is full.
  2. Splice the same file on an online splicer, then store one file to the SD card.

https://clideo.com/merge-mp3

Did you look at the few DFR examples, or the hundreds of others here in the forum? Basic structure wrong! Which you've presumably now seen anyway from : @van_der_decken's example?

In my own example, below (running on a Uno) I've assumed that despite your sparse details, you will want something more going on!

/*
   Corrected version of sketch by @kenne76 in post
  https://forum.arduino.cc/t/play-the-same-song-repeatedly-with-df-mini-player/1304414
*/

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

SoftwareSerial softwareSerial(10, 11);
DFRobotDFPlayerMini myPlayer;

void setup()
{
  softwareSerial.begin(9600);

  // These two wrongly placed in loop()
  myPlayer.begin(softwareSerial);
  myPlayer.volume(15);
  //  delay(1000); // Sometimes needed
}

void loop()
{
  myPlayer.play(1);
  delay(10000); // At least as long as track 1.
}

Can the Mini player loop without generating a delay or glitch, so that the sound is continuous?

A real one can. Clones sometimes have a gap between the end and the next start.

Thank you, this solution works!

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