python播放tksnack_tkSnack:当第一个声音结束时,如何播放第二个声音

我希望我的脚本在第一个声音结束时播放第二个声音。来自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...
摘要由CSDN通过智能技术生成

我希望我的脚本在第一个声音结束时播放第二个声音。来自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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值