pythonpython-2.7winsound

Playing sound and a program


What I want to do is get an audio file to play while a def (function) is running. I've looked it up and seen that threading works but it is wayyyy to complicated for me to work out. Is there a way you guys can explain it to me? I was using winsound to play the audio file, and SND_FILENAME.


Solution

  • Try this:

    from multiprocessing import Process
    
    def play():
        #winsound stuff
    
    def function():
        #functiony stuff
    
    if __name__ == '__main__':
        p = Process(target=play)
        d = Process(target=function)
        p.start()
        d.start()