html5音频-Canplay事件不会在Safari上启动(Mac桌面) [英] html5 audio - canplay event doesn't fire on Safari (Mac Desktop)

查看:360
本文介绍了html5音频-Canplay事件不会在Safari上启动(Mac桌面)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过html5音频标签播放一些音频(如果有任何区别,请使用Buzz作为包装器.)

I'm trying to play some audio through the html5 audio tag (using Buzz as a wrapper if that makes any difference).

因为音频定时从另一个事件开始,所以我一直在听canplay事件.

Because the audio is timed to start with another event, I've been listening for the canplay event.

它可以在Chrome和Firefox上完美运行,但Safari不会触发canplay事件.

It works perfectly on Chrome and Firefox, but Safari doesn't trigger the canplay event.

我为所有可能的音频事件添加了事件处理程序,据我所知,它只会触发loadstartloadedmetadata事件.

I've added event handlers for all the possible audio events available and as far as I can tell it only fires the loadstart and loadedmetadata event.

当触发loadedmetadata时,音频元素在检查器中看起来不错,但这是停止的地方.

When the loadedmetadata is triggered the audio element looks fine in the inspector, but that's where it stops.

我猜想这是与设置为 not 自动播放的元素有关的..由于某种原因,这似乎导致Safari停止在那里(如果我自动播放,则所有事件被触发).

I'm guessing that's the cause has something to do with the element set to not auto-play.. for some reason that seems to cause Safari to stop there (if I autoplay then all the events are triggered).

您是否遇到相同的问题,是否有办法不自动播放声音却触发canplay事件?

Are you getting the same problem and is there a way to not auto-play the sound but get the canplay event to fire?

我的Safari版本是5.1.3(7534.53.10)

My Safari version is 5.1.3 (7534.53.10)

推荐答案

好,解决此问题的方法只是将声音设置为自动播放并收听canplay事件.当触发时,我可以暂停它并等待其他事件触发.

Ok, the work around the problem is simply to set the sound to auto-play and listen to the canplay event. When that triggers I can then pause it and wait for my other event to trigger.

不得不稍微改变一下逻辑,但这似乎行得通.

Had to move the logic around a bit but that seems to work ok.

这篇关于html5音频-Canplay事件不会在Safari上启动(Mac桌面)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆