Page 1 of 1

Cytron MP3 shield: random play?

PostPosted: Tue Dec 01, 2015 9:05 pm
by JustKelly
Hi. I'm doing an animatronic setup and want to use your shield for the audio portion. Basically, what I need to do is this:

1) Wait a little while
2) Play a random mp3 file on the SD card
3) Repeat

It looks like mp3.PlayTrack(track #) will do what I need, but is there a way to read the SD card and see how many mp3 files there are? That way, "track #" above can be random(number of files). I can use a constant at the moment, but if we ever go back and add/subtract audio tracks, I'd have to change the constant every time, which is a pain in the neck.

Any advice would be appreciated. Thanks.

Re: Cytron MP3 shield: random play?

PostPosted: Wed Dec 02, 2015 1:10 am
by bengchet
Hi JustKelly,

You might try this out.

First, use mp3.playTrack("YourFolder",1000); or any number that you think it is impossible in that folder. It should be no response in return.
Then, use mp3.getTrackNo to get current track no, in fact it is the total number of files in that particular folder.

Hope it helps. :D

Re: Cytron MP3 shield: random play?

PostPosted: Wed Dec 02, 2015 3:33 am
by JustKelly
bengchet WROTE:Hi JustKelly,

You might try this out.

First, use mp3.playTrack("YourFolder",1000); or any number that you think it is impossible in that folder. It should be no response in return.
Then, use mp3.getTrackNo to get current track no, in fact it is the total number of files in that particular folder.

Hope it helps. :D


Heh! Neat trick. I'll give that a try tonight; thanks!

Re: Cytron MP3 shield: random play?

PostPosted: Wed Dec 02, 2015 8:50 am
by JustKelly
Yup, it worked just fine! That takes care of the sound F/X portion, so on to the blinky-lights. Thanks for your help!