I am using an Arduino UNO and a Seeedstudio Music Shield (http://seeedstudio.com/wiki/Music_Shield) to run a very simple project, which is giving me some problems anyway.. Basically, when someone is close enough to a proximity sensor (Analog5), a stored sound file should start playing. The file would play till the end (2.30 min), then the arduino would wait some time and start the process again so that the next person that comes in will enjoy the same treat.You have to imagine that the sensor is in front of a mirror and the file plays only (but for all it's length) when someone approches it.. Of course this is quite hard cause if someone will remain in front of the mirror for longer time then the file will play again... but that is part of the game I guess.

Here is my code. At the moment I can get the file to play when the sensor goes under a threshold but then it won't play again a second time.. the process kind of freezes it self after a first reproduction. ..thanks a lot!!

Ok, big update. Using the Play() function as it was would have not allow me to just play a file, as that function never returns. I have written a new one (JPlay) and now it works much better. I can now get the patch to run as many times as I want... everytime the distance sensor goes over the threshold the file play for all it's length.

Now, would be good to write something to avoid the file to play twice if the person remains in front of the sensor. Is this clear enough? or should I try explain it differently?

first attempt which doesn't work (it plays the file when something is close to the sensor, but it will play it twice if the sensor is still covered)