SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By andrewsleigh
#199441
Hi,
I'm trying to build a simple MP3 player wi the Sparkfun MP3 shield, that will play all the tracks in a specified directory in order, but all the user to pause or skip tracks during playback

I've got code that will enable pausing and I've got code that will play all tracks in a directory (very crudely), but I can't do both at the same time. If I want to loop through all the tracks, I need to check for the isPlaying() function to be false before doing anything else, which then also blocks other actions, such as skipping or pausing.

I feel like this should be pretty basic and I am just missing something obvious. Can anyone help?

Code attached (I had to save it as a txt file, but it is an Arduino sketch), but in short, if I use this code:
Code: Select all
  result = MP3player.playMP3(trackToPlay);
  // wait til playback of this track is finished
   while (MP3player.isPlaying()) 
I can play one file, then when it's finished move onto play the next one, but then I can't do other things like skipping. And if I remove the isPlaying() function, it runs through the loop of tracks to play instantly and so never plays more than one.
You do not have the required permissions to view the files attached to this post.