pygame 中的自动声音回声意外

问题描述

我正在 Tkinter 和 pygame 中制作一个钟声。但是,它回响了整点的声音,这不是我想要的。如何让它只发一次声而没有回声?注意:变量 clock.chime 是 chime 模式(1、2、3、off)的 int,clock 是主 tkinter 窗口。 这是我的代码

while True:
    try:
        d = datetime.Now() #updates time
        hour = d.strftime("%I")
        mins = d.strftime("%M")
        secs = d.strftime("%s")
        day =  d.strftime("%A")
        clock.update()
        if mins=='00' and secs=='00' and clock.chime>0 and pygame.mixer.music.get_busy()==False: #chimes on the hour,but echoing
            try:
                pygame.mixer.music.load(str(clock.chime)+'.wav')
                pygame.mixer.music.play()
            except:
                messageBox.showerror('Error','File '+str(clock.chime)+'.wav cannot be found.') #alerts if chime file is missing
        time.sleep(0.01)
    except: #detects when window is closed
        break

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)