I'm using Python 3.9.7 and playsound 1.2.2 (as latest version had issues). When parameter block=False
, there's no sound and the script executed without any error. I tried both *.mp3 and *.wav file.
How to make the parameter block=False
work with sound? It enables my script to continue running without waiting for the mp3 to finish playing.
**New discovery: apparently block=False
worked when script is run in IPython console but not in a terminal. How to make it work through batch file?
python script (test.py):
from playsound import playsound
# playsound("myfile.mp3") # work fine with sound
playsound("myfile.mp3", block=False) # execute without error but no sound
batch file:
set root=D:\Anaconda3
call %root%\Scripts\activate.bat %root%
%root%\python.exe "D:\test.py"
pause
CodePudding user response:
After reading more on IPython console and some trial & error, found a working solution which is modify the batch file to run the script using Anaconda's ipython.exe located in the Anaconda3/Scripts directory:
set root=D:\Anaconda3
call %root%\Scripts\activate.bat %root%
%root%\Scripts\ipython.exe -i "D:\test.py"
pause