I want a Python script that I can run in the background on my Windows machine which plays a sound file.
I have two different scripts which only work when I copy and paste the code into the Python interpreter. The sound will play successfully.
If instead I go to cmd and type python run.py, the script will run with the same standard out, but there will be no sound played.
# can only hear sound when this code is run in interpreter
from pygame import mixer
mixer.init()
mixer.music.load("C:\\Sound.mp3")
mixer.music.play()
# can only hear sound when this code is run in interpreter
import winsound
winsound.PlaySound("C:\\Sound.wav", winsound.SND_ASYNC)
How to resolve this?