0
How to stop audio in python ?
Please introduce a module that I can use it in playing a sound and then stop it . I used winsound and multiprocessing modules to do this but it didn't work.
5 Antworten
0
Knight ,
I haven't used pygame, but the code looks inconsistent in the calling syntax.
Are you sure you aren't supposed to do one of these instead?
sound.stop()
or
channel = sound.stop()
?
0
For winsound, you should be able to use the following to stop the current sound from playing:
winsound.Playsound(None, winsound.SND_PURGE)
If you just need to stop a sound and immediately start playing another sound, then you can just call the next sound to play. You should be using the SND_ASYNC flag whenever you make the call to play your sound(s).
This is all assuming that you're running this code on a Windows OS.
With multiprocessing there isn't an option to stop the sound. It will play until the file ends, unless you Kill/terminate the process.
0
Can Anyone Explain Me MySQL From Basics