简体   繁体   中英

Python check if Winsound is playing a sound

I need to make a script that checks if Winsound is playing the sound that I requested. Winsound doesn't have this built in but I cant use pygame because I need mp3 support. I found a user that had the same question on here but the code the answer provided isnt working for me link here's the code ive tried

import threading
import winsound

t = threading.Thread(target=winsound.PlaySound, args=["bt.wav"])
while True:
    print("playing")
    t.join(0)
    if not t.is_alive():
        print("stopped")

I get the error "RuntimeError: cannot join thread before it is started" but I have tried looking this up and I cant solve it because I literally have no knowledge about the threading module. Any help in fixing this would be appreciated.

I need to make a script that checks if Winsound is playing the sound that I requested. Winsound doesn't have this built in but I cant use pygame because I need mp3 support. I found a user that had the same question on here but the code the answer provided isnt working for me link here's the code ive tried

import threading
import winsound

t = threading.Thread(target=winsound.PlaySound, args=["bt.wav"])
while True:
    print("playing")
    t.join(0)
    if not t.is_alive():
        print("stopped")

I get the error "RuntimeError: cannot join thread before it is started" but I have tried looking this up and I cant solve it because I literally have no knowledge about the threading module. Any help in fixing this would be appreciated.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM