@peeshder Hello Peter..... this will do what you want.
If you are studying...... do not submit it as it is. I worked it through for someone else, and they added the randomness........ and since then it has been used for teaching somewhere...... beware.
Work through it and understand it and try to make your own version (maybe better?).
I have hacked out the bit you want from a larger patch....... so there will be some messages being sent that are unnecessary, and receive objects that will never receive anything...... and some error messages to the terminal.............. its up to you to make it perfect.......
madness.zip
If you leave it playing it will play "random" and if you re-click the toggle it will play the next (random track) immediately.....
You will need pd-extended.........
By the way..... [random] is not random in the "human" sense of the word..... it is a predetermined series of values that do not repeat before the end of the series...... a very "lame" mathematical definition of a "group" of values that do not repeat more often than "expected" and feed an "even distribution" of the said values.........never mind......... I am not a fan ( a thing that turns rapidly (maybe) propelling atoms of oxygen, hydrogen, carbon dioxide (and monoxide (but not much fortunately) and nitrogen with a little bit of argon and (non-exhaustive list) other elements to the output of the said "FAN".....
David.