I've just started playing around with these DFPlayer modules using the DFRobotDFPlayermini library. I was trying to modify the getStarted example to play a series of MP3s end to end rather than 3 second bursts of each one. I was also frustrated that there didn't seem to be a reliable way to detect when an item has finished playing (without using the BUSY pin).
However, I found where you can switch on DEBUG mode within the library (remove the comment in front of #define _DEBUG in the .h file). You can then see the command sequences being sent to the DFPlayer and what is being received back from it. If the command is sent with a 'Reply required' bit set (as the library does) in the command the module acknowledges the receipt of the command immediately. A little later it may send further messages reporting on the progress of the command. For commands that start a song playing this will include the message that the song has finished. In the example the arrival of these replies is detected and processed by
if (myDFPlayer.available()) {
printDetail(myDFPlayer.readType(), myDFPlayer.read());
}
. However, once processed the information is no longer available. You need to set a busy flag when you start the sound playing and reset it e.g. within case DFPlayerPlayFinished:
Having added a flag I was still finding my sounds were not playing to the end. Every second sound was being cut short by the next sound being started. This turned out to be because the Finished message is apparently being sent twice by the module. The first message was clearing my busy flag so I was queuing up another sound but the second copy of the Finished message was then clearing the busy flag of the subsequent sound. You can resolve this by changing the if (myDFPlayer) { } to while (myDFPlayer) { }. All copies of the finished messages then get consumed before your code continues.
I can now play a series of sounds and reliably detect when each one finishes before queuing the next.
NB I also had noise problems with the on-board amplifier and have concluded the solution is not to use it and amplify the DAC signals externally.