是否可以在 onMouseover 事件上顺序播放多个声音文件?
我知道如何在鼠标悬停事件上一次播放一个声音文件,例如
onMouseover="Playsound(1.wav)
但是,我想在一个声音文件上依次播放多个声音文件(1.wav、2.wav、3.wav 等)将鼠标悬停在图像或其他元素上。
有可能吗?
提前致谢。
I know how to play a single sound file at a time onMouseover event e.g
onMouseover="Playsound(1.wav)
However, I want to play multiple soundfiles (1.wav, 2.wav, 3.wav etc) sequentially on a single mouseover either on an image or other element.
Is it possible at all?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您知道声音的长度,则可以使用 setTimeout 按顺序播放它们
if you know lengths of the sounds, you can use setTimeout to play them sequentially
您可以通过将函数附加到鼠标悬停事件来做到这一点,即
You could do it by attaching a function to the event mouseover i.e.
更好的方法是使用 html5 音频元素并注册一个用于剪辑结束的处理程序:
setTimeout 不适用于需要精确计时的情况。如果第一个音频剪辑有点滞后,您的 setTimeout 将紧随其后停止。你还依赖上帝知道客户端发生了什么。 :-)
The better way to do it is to use html5 audio element and register a handler for the ending of the clip:
setTimeout is not great for when precise timing is required. If the first audio clip was a little laggy, your setTimeout will stop on its heels. You are also relying on god knows what is going on at the client. :-)