0

I working in python on computers in a lab where I do not have root privileges and can't get any libraries installed. Someone I am helping is writing a game and wants to add audio. We can play sounds with something like this

subprocess.call(["afplay","gun_battle_sound-ReamProductions-1158375208.wav"])

but everything stops until the sound is done playing. Is there a way to keep things moving while the audio is playing? Is there a library that we can just copy? We are using the graphics module from Zelle, so I am looking for something like that - simple to use and install.

Thank you!

  • Regarding your library Installation problem: What about using virtualenv to create your own local python distribution (in your home directory) where you can install all the libraries you want (well, maybe not heavy-stuff like scipy). The only thing you need: virtualenv has to be installed/available! – sascha Jul 28 '15 at 00:21
  • For what it's worth, there's [`subprocess.Popen`](http://stackoverflow.com/questions/16071866/non-blocking-subprocess-call), but then you have to deal with zombies. – NightShadeQueen Jul 28 '15 at 00:38
  • Hmm. I tried Popen - `>>> subprocess.Popen(["afplay","gun_battle_sound-ReamProductions-1158375208.wav"]) ` But it didn't play - it just returned the object, as shown. I'm afraid to as it to install anything, but maybe I should get over it and ask them about virtualenv. It sounds like a nice option to have. – user3276777 Jul 28 '15 at 00:59
  • For what it's worth, I have success using `subprocess.Popen` executing `afplay` to play a WAV file (using the same arguments) in Python 2.7. – Jacob Budin Jul 28 '15 at 01:24
  • OK, I tried it again and it worked (?!?) Thanks, all! – user3276777 Jul 28 '15 at 01:37

1 Answers1

0

Pyglet is completely copyable and easy to download. Otherwise you will probably need to create a thread from threading just for the sound to play on.