Mac 桌面版 Safari:HTML 5 音频“结束”事件不触发问题
我只想使用 HTML5 音频功能顺序播放多个音频文件。每次播放结束时,都会触发“结束”事件以加载下一个音频。但在桌面版 Safari 5.1(Mac 上)中,我发现“结束”事件仅在第一次播放结束时触发。加载并播放第二个音频后,即使音频播放完成,“结束”事件也不会再次触发(我通过“timeupdate”事件跟踪此事件)。即使我手动播放任何其他音频文件,“结束”事件也不会再次触发。但在Chrome和mobile safari中,这个问题似乎不存在,音频播放器可以从第一个音频连续播放到最后一个音频。这是 Mac OS X 的 Safari 5.1 的错误吗? (我没有在Windows中测试)
目前,我只能使用“timeupdate”事件来检查播放是否结束。
I just want to play several audio files sequentially using HTML5 Audio function. At the end of each play, the "ended" event fires to load next audio. But in Safari 5.1 for desktop (on Mac), i found the "ended" event only fired at the end of the first play. After loading and playing the second audio, the "ended" event didn't fire again even when the audio play did finished (I tracked this by "timeupdate" event). Even when I manually played any other audio files, the "ended" event didn't fire again. But in Chrome and mobile safari, this problem seems not existed and the audio player can play from the first audio to the last audio continuously. Is this the bug of Safari 5.1 for Mac OS X? (I didn't test it in Windows)
Currently, I can only use "timeupdate" event to check if the play ended or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是一个烦人的错误。您可以通过更改每个文件的音频元素的 id 来解决此问题。下面是一些示例代码,您可以了解一下:
Yes this is an annoying bug. You can work around this by changing the id of the audio element for each file. Here is some sample code to get an idea: