I use the DFR Mini MP3 Player module with the DFR library "DFRobotDFPlayerMini.h".
After executing the command
randomAll();
I've been assuming that it plays all files on the micro-SD card, at 'random'. For any of the several file and folder structures. Such as:
folders \01 - \99 of up to 255 files (001.mp3 - 255.mp3)
one large folder mp3\0001.mp3 - 1234.mp3 etc.
a mix of 'regular' and 'large folders', the latter with files 0001.mp4 - 1234.mp3 etc.
But I now think that's not true. I tested it the only way I know, by using the command
readCurrentFileNumber();
After about a hundred readings, with a single folder 'mp3' holding 911 files with the 4-digit prefix, the highest number was 255.
That would be a fraction of the 3,600 files in my current project.
I could resort to coding my own random playing, but getting automatic play of each complete music track seems a challenge.
int DFRobotDFPlayerMini::readCurrentFileNumber(uint8_t device)
readCurrentFileNumber() returns an int. Which data type are you using to hold the value that it returns ?
But it is only used to select the device type being used
int DFRobotDFPlayerMini::readCurrentFileNumber(uint8_t device){
switch (device) {
case DFPLAYER_DEVICE_U_DISK:
sendStack(0x4B);
break;
case DFPLAYER_DEVICE_SD:
sendStack(0x4C);
break;
case DFPLAYER_DEVICE_FLASH:
sendStack(0x4D);
break;
default:
break;
}
There are two commands available:
readCurrentFileNumber(uint8_t device);
readCurrentFileNumber();
I'm using the latter, and it's declared as an int.
while (1 == 1)
{
myDFPlayer.randomAll(); //Random play all the mp3.
delay(2000);
int currentTrack = myDFPlayer.readCurrentFileNumber();
Serial.print("currentTrack (raw) = ");
Serial.println(currentTrack);
}
system
Closed
December 15, 2022, 3:08pm
6
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.