Search code examples
rubycore-audio

How to stop afplay after a certain amount of time


I made a battleship game in ruby. I have a method in my file that uses afplay at the end of the game. I am unable to stop the audio playback, it plays a song. I found the -t for afplay but can't find anywhere that says how to implement it. I have and am trying to throw it in there to see what works but still thought this would be a good resource. I would like to stop the song after about 20sec or so. ctrl-c doesn't work :(. Thanks for any help.

pid = fork{ exec 'afplay', "../filename.mp3" }


Solution

  • I finally found it! killall afplay For the timer I added sleep 20 before the killall afplay