I want to loop the sound with winsound but it doesn't work with
winsound.PlaySound(song[0], winsound.SND_ASYNC + winsound.SND_LOOP
and
winsound.PlaySound(song[0], winsound.SND_FILENAME | winsound.SND_ASYNC + winsound.SND_LOOP
The code just closes after this. What's the problem?
To use SND_LOOP, you have to use SND_ASYNC, and that means the sound is playing in a separate thread. The PlaySound
function will return immediately. Your code is presumably going to do something else while the sound plays. If nothing else, do time.sleep(5)
in a loop.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.