I'm tring to run a script that would play music via a process. the code below is a stripped down version of my code but it's good enough to replicate the problem. If I call the normal()
procedure I hear music so I know the procedure is correct and everything is connected properly, however, if I call normal()
using multiprocessing there is no sound... It runs normal()
but still no audio...
Any suggestions? thanks!
#!/usr/bin/python
#
# Import required Python libraries
import pygame, time
import multiprocessing as mp
localtime = time.asctime( time.localtime(time.time()) )
pygame.init()
cs = 0
def normal( cs ):
# main loop
try:
if cs == 1:
while cs == 1:
print " Starting normal function"
pygame.mixer.music.load('/home/user/scripts/music.mp3')
pygame.mixer.music.play()
time.sleep(20)
pygame.mixer.music.stop()
#return;
except KeyboardInterrupt:
print "Quit"
try:
print " Starting music"
# play here
cs = 1
p2 = mp.Process(target=normal, args=(cs,))
p2.start()
p2.terminate()
#normal( cs )
except KeyboardInterrupt:
print " Quit"
# End script