iOS 10更新
禁止自动播放已取消iOS 10 – 但有一些限制(例如A可以自动播放,如果没有音轨)。
iOS 9和之前
从iOS 6.1,它不再可能在iPad上自动播放视频。
我的假设是他们为什么禁用自动播放功能?
好吧,许多设备所有者在他们的设备上具有数据使用/带宽限制,我认为苹果觉得用户自己应该决定何时启动带宽使用。
经过一番研究后,我发现苹果文档中有关iOS设备上的自动播放的以下摘录,以确认我的假设:
“Apple has made the decision to disable the automatic playing of video
on iOS devices, through both script and attribute implementations.
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
auto-play are disabled. No data is loaded until the user initiates it.” – 07001
这里有一个单独的警告Safari HTML5 Reference page上说明为什么嵌入式媒体无法在iOS上的Safari播放:
Warning: To prevent unsolicited downloads over cellular networks at
the user’s expense, embedded media cannot be played automatically in
Safari on iOS—the user always initiates playback. A controller is
automatically supplied on iPhone or iPod touch once playback in
initiated, but for iPad you must either set the controls attribute or
provide a controller using JavaScript.
这意味着(在代码方面),除非play()或load()方法由用户动作(例如点击事件)触发,否则Javascript的play()和load()方法是不活动的,直到用户启动回放为止。
基本上,用户启动的播放按钮工作,但是
一个onLoad =“play()”事件不。
例如,这将播放电影:
而下面的iOS在iOS上什么都不做: