Open supermandt opened 2 years ago
This method is not built in, but you can make one yourself:
bool mp3IsPlaying() {
return DF1201S.getTotalTime() > DF1201S.getCurTime();
}
Actually, the command 'AT+PLAY=PP\r\n' can directly achieve the functionality you need.
However, in the library, to make it easier to distinguish, we added a flag called 'pauseFlag.' In the future, I will use this flag to create an 'isplaying()' API. Thank you for your suggestion.
@Nickman87, Thank you so much for your feedback! After my further testing, I found that when the current mode is set to DF1201S.setPlayMode(DF1201S.SINGLE);, the song will automatically stop after it finishes playing. This indeed can cause confusion with the flags in the code. So, I have added an interface with the hope of avoiding this situation. It will use getCurTime() to detect and refresh the flag.
bool DFRobot_DF1201S::isPlaying()
{
uint16_t temp = getCurTime();
delay(2000);
if (getCurTime() != temp) {
pauseFlag = 1;
} else {
pauseFlag = 0;
}
return pauseFlag;
}
How can i see if music is currently playing? I have a button where if the music is playing, I want to stop it. then if you touch button again it will start playing the next track. The regular dfplayer mini has a function called isplaying() , does this DFROBOT PRO have a similar function? If not, we need this. Thanks.