mp3 advancing

I’m just toying around making an mp3 player and came to a problem. I’ve got everything to work just fine… but I don’t know how to get the player to recognize that the current track is finished and get it to get the next track… how can this be done? thanks for any help!