Playsound is unable to play audio in a separate process when launched from PyCharm, while being able to work properly when launched from the command line.
Trying to implement this solution leads to nothing being played despite p.is_alive() returning True.
This is the code I've tried.
import multiprocessing
from playsound import playsound
def use_playsound(audio_file):
p = multiprocessing.Process(target=playsound, args=(audio_file,))
p.start()
print(p.is_alive())
input("press ENTER to stop playback")
p.terminate()
def main():
use_playsound("test.mp3")
if __name__ == '__main__':
main()
If I p.join() the process after starting it, then the sound plays successfully.
Adding block=False or block=True doesn't help.
Modifying the code so that the Process is started in main(), leaving only the playsound call in the use_playsound function does not help. Doing that then setting block=False or block=True does not help.
Raising a BaseException after p.start() makes the sound play. However when I let the program exit successfully after pressing Enter, the sound still does not play.