HTML5 音频在 iOS 4 上的限制?播放列表、背景等
我一直在 iOS 4 上评估 HTML5 音频,并试图了解它的局限性。据我所知...
- 可以在后台播放音频
- 不可能在曲目完成后在后台触发JavaScript事件
- 可以在屏幕关闭时触发JavaScript事件,但 Safari 必须 位于前台(在关闭屏幕之前)
我当前项目的目标是创建一个动态播放列表,即使 Safari不在前台。目前 HTML5 音频在 iOS 上的工作方式是否可行?
如果有人有更多信息,我很好奇 JavaScript 事件链在 iOS 上是如何工作的。似乎您可以连续排列声音,但它必须在“人类”功能发生后不久发生(例如,点击一个元素)。任何其他试图在人类功能之外排队的声音都被拒绝播放。
另外...
是否有可能触发事件以将真实的 iOS 应用程序移动到下一个轨道?似乎只允许应用程序完成其当前的音频流,然后进入空闲状态。只是想弄清楚这里的所有角度!
I've been evaluating HTML5 audio on iOS 4 and have been trying to understand its limitations. From what I can tell...
- It is possible to play audio in the background
- It is not possible to fire JavaScript events in the background upon track completion
- It is possible to fire JavaScript events while the screen is off, but Safari must be in the foreground (before turning the screen off)
My goal for this current project is to create a dynamic playlist that will continue to fire events and move to the next track even while Safari is not in the foreground. Is this possible with the current way HTML5 audio works on iOS?
I am curious about how the chaining of JavaScript events works on iOS if anyone has additional information. It seems that you are allowed to queue back to back sounds, but it must happen shortly after a "human" function happens (for example, tapping an element). Anything else that tries to queue a sound outside of this human function is denied the ability to play.
Also...
Is it even possible to have events that fire to move a real iOS application to the next track? It seems as if the application is only allowed to finish its current audio stream and then it goes into an idle state. Just trying to figure out all the angles here!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个很老的问题,所以我不确定您是否已经找到答案。
我知道的一件事是,音频剪辑无法通过 JavaScript 在移动 Safari 上播放。
使用 HTML5 在 iPad 上自动播放音频文件
播放音频的唯一方法是通过单击事件。 3.x 上不是这种情况,但 4.x 上却是这样。这是因为 Apple 不希望 Web 应用程序以编程方式在 3G 连接上下载音频,因此他们强制用户启动它。
我认为如果所有曲目都开始下载(缓存),那么这可能是可能的。我会尝试强制用户启动一个轨道,同时在所有其他轨道上调用 .load() (在同一个单击处理程序中)。这将强制 iOS 设备开始下载音轨,并且您也许可以播放下一首曲目(但不确定)。
This is quite an old question, so I'm not sure if you've found an answer already or not.
One thing I know is that an audio clip cannot be played via JavaScript on mobile Safari.
Autoplay audio files on an iPad with HTML5
The only way to make audio play, is through a click event. This wasn't the case on 3.x, but on 4.x it is. This is because Apple doesn't want the webapp to download audio on a 3g connection programmatically, so they force the user to initiate it.
I would think that if all of the tracks were started downloading (cached), then it may be possible. I would try forcing the user to start one track, and at the same time call .load() on all of the other tracks (in the same click handler). This will force the iOS device to start downloading the audio tracks, and you may be able to play the next track (not sure though).