javascript - 在 iOS5 中自动播放 HTML5 音频/视频

标签 javascript html html5-video html5-audio

我有一个具有音效的 HTML5 网络应用程序。我正在尝试让这些效果在 iOS5 中运行,但终究无法实现。

想知道是否有人有任何变通办法让 JS 控制 iOS5 中的 HTML5 音频/视频控件。

或者甚至是一种一次单击即可控制多个音频文件的方法。就目前而言,如果我有 10 个音效,我需要 10 次用户点击才能控制所有音效,这荒谬!

最佳答案

荒谬,但你必须从 iPhone 或任何手机的 Angular 来看它。这是一款移动电话,通过蜂窝网络进行带宽限制,许多人从最近的 Sprint 商业广告中了解到这一点。他们不希望用户超出他们的带宽限制,因为一些网站在他们自己不采取行动的情况下向他们的手机发送大量数据。

以下摘自官方Safari Developer Library更多详情。

User Control of Downloads Over Cellular Networks

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.

This plays the movie: <input type="button" value="Play" onClick="document.myMovie.play()">

This does nothing on iOS: <body onLoad="document.myMovie.play()">

关于javascript - 在 iOS5 中自动播放 HTML5 音频/视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8044447/

相关文章:

javascript - 如何处理非平凡的表单输入? JSP 还是 Javascript?

javascript - Browserify 导入/要求?

javascript - 使用外部 JS 库 Angular 2

javascript - 无法在 Firefox 中为同一输入字段触发 ONKEYDOWN 和 ONCHANGE 事件

javascript - 在页面的其余部分完成加载后延迟加载 html5 视频

javascript - Grunt watch -- 长时间延迟

javascript - 使用 JQuery,如何停止向上传播 DOM 的单击事件?

javascript - 显示椭圆形黑球的 Canvas 弹跳球

css - 让全屏 HTML5 视频背景模糊工作?

javascript - 结束事件 videojs 不工作