英文:
How to skip waiting for winsound to end?
问题
winsound播放时,Python会等待音频结束。我的目标是通过winsound播放声音,同时在声音仍在播放时继续执行。是否有解决方法?
英文:
Every time winsound is played python waits until audio ends. My goal is to play sound via winsound and continue while sound is still playing. Is there a workaround?
答案1
得分: 2
使用多个线程,如 @xihtyM 所提到的,是不必要的。文档 描述了方法 winsound.PlaySound
的几个标志。
你要寻找的是:
import winsound
winsound.PlaySound('*' , winsound.SND_ASYNC)
这个标志让方法立即返回。
英文:
Using multiple threads as @xihtyM mentions is not necessary. The documentation describes several flags for the method winsound.PlaySound
.
The one you are looking for is:
import winsound
winsound.PlaySound('*', windsound.SND_ASYNC)
this flag let the method return immediately.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论