Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用该winsound库来异步播放文件。但是,我想知道声音何时播放完毕。如果声音完成,那么我保持flag设置为 1。否则,我设置flag为 0。
winsound
flag
这是我当前的代码:
import winsound winsound.PlaySound('c:\\audiocheck.net_whitenoise.wav',winsound.SND_ALIAS | winsound.SND_ASYNC) flag = 1 print(flag)
import winsound import time start = time.time() winsound.PlaySound('c:\\audiocheck.net_whitenoise.wav',winsound.SND_ALIAS | winsound.SND_ASYNC) flag = 1 while flag == 1: elapsed = time.time() - start if elapsed >= 10: flag = 0