Hi,
Creating an MP3 radio with 2 pots. One for volume and one for stations. I'm using the Sparkfun MP3 shield, basing my program on their example. Here is the shield SparkFun MP3 Player Shield - DEV-12660 - SparkFun Electronics and the datasheet http://www.sparkfun.com/datasheets/Components/SMD/vs1053.pdf I need to change tracks on the fly. I've got volume working on the fly but can't change tracks on the fly . Specifically it won't go to the next track until the current one is finished. When I try to use track.stop(); it just screws up my program , constantly trying to stop, even though it is in separate function that is not being called yet. How do I stop the track playing and go to the next track on the fly?
Any help is appreciated.
Here is where I determine if i need to the stop track.
if(stationRead != prevStation)
{
stationChange();
if (prevStation!=station)
{
randNumber=random(14);
if(station==99) // radio noise track, in between stations
{
trackNumber=0;
randNumber=0;
}
stopTrack();
sprintf(trackName, "track%03d.mp3", (stationValue+randNumber));
playMP3(trackName);
prevStation=station;
}
}
Here is the problem area.
void stopTrack()
{
Serial.println("In Stop Track");
//tell MP3 chip to do a soft reset. Fixes garbles at end, and clears its buffer.
Mp3WriteRegister(SCI_MODE, 0x48, MP3_RESET);
track.close(); //Close out this track
}
I have attached the complete code.
Radio_MP36.ino (9.97 KB)