我希望我的脚本在第一个声音结束时播放第二个声音。来自tkSnack documentation:play ( )
Plays the sound. All options are ignored if play() is used to resume a paused play options.
If a play() command is issued while another one is in progress,
the latter one is queued up and starts to play as soon as possible.
所以,我认为在播放一首歌的时候调用sound对象上的play方法会导致第二首歌在这首歌结束时开始。在
不幸的是,这似乎没有发生。实际上,当我对sound对象调用read方法时,为了加载音频文件,播放器停止播放。在
如何加载音频?在
我也尝试过使用两个不同的声音对象,但这会导致重复播放。在
到目前为止,我找到的唯一解决方案是对play方法使用blocking选项。并将其添加到循环中:
^{pr2}$
然而,这远不是一个好的解决方案,因为它会阻塞整个应用程序,即使我在守护进程线程中启动它。在
下面是一个示例代码:import Tkinter, tkSnack, time
win = Tkinter.Tk()
tkSnack.initializeSnack(win)
snd = tkSnack.Sound()
def play1():
snd.read('/home/francesco/Musica/Andrea Bocelli - Ave Maria.