如何在 soundmanager2 中连续播放声音
我如何在 soundmanager2 中开始一个又一个的声音,我的意思是当第一个声音结束时,第二个声音开始,第二个声音结束时第三个声音开始等等。
How can i start sound after sound in soundmanager2, i mean when the first sound ends, second sound to start and when the second end the third start and etc and etc..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
托盘使用递归,唯一的问题可能发生,当在数组中放置相同的声音两次(链是无穷大)
tray use recursion, the only problem can occur, when in array you put same sound twice(chain be infinity)
文档中有一个如何执行此操作的示例(请参阅演示 4a )。
play
方法采用一个对象作为参数。该对象包含一组选项。这些选项之一是onfinish
回调函数:multiShotEvents
选项必须设置为true
才能引发onfinish
> 每个声音完成后触发的事件。默认情况下,只有声音结束后才会触发。您确实可以通过这种方式对任意数量的声音进行排队。
There is an example of how to do this in the documentation (see Demo 4a). The
play
method takes an object as an argument. That object contains a set of options. One of those options is anonfinish
callback function:The
multiShotEvents
option has to be set totrue
to cause theonfinish
event to fire upon completion of each sound. By default it will only fire once sounds have finished.You could queue up as many sounds as you wanted to this way really.
我花了大约 3 个小时才弄清楚..但它是:
It took me like 3 hours to figure out.. but here it is:
除了 Ashot 的答案和所有其他答案之外,您还可以在创建声音时设置 onfinish 功能,而不仅仅是在播放声音时设置,例如:
...如果您需要在声音已经播放后更改 onfinish 功能,你可以这样做:
In addition to Ashot's answer and all the others, you can set the onfinish function when you create the sound, not only when you play it, for example:
...and if you need to change the onfinish function once the sound is already playing, you can do so like this: