首页 > 为什么在手机或平板的safari上audio在ajax回调中无法调用Play

为什么在手机或平板的safari上audio在ajax回调中无法调用Play

在手机或平板的safari上,如果一个audio标签在一个异步ajax请求完成时,调用play,audio将无法播放,为什么?


这是 Apple 特意这样设计的,不允许自动播放,必须由用户触发播放行为。主要考虑到用户可能不是WiFi网络,而音频通常较大,会耗费很多流量,流量是要花钱的。

In Safari on iOS (for all devices, including iPad), where the user may be on a cellular network and be charged per data unit, preload and autoplay are disabled. No data is loaded until the user initiates it. This means the JavaScript play() and load() methods are also inactive until the user initiates playback, unless the play() or load() method is triggered by user action. In other words, a user-initiated Play button works, but an onLoad="play()" event does not.

请参考 https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html

【热门文章】
【热门文章】