在HTML5移动网络应用程序音频延迟 [英] Audio delay on HTML5 mobile web app

查看:396
本文介绍了在HTML5移动网络应用程序音频延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用HTML5&放一个移动网络应用程序;的JavaScript。我们的目标是有,经过触摸事件播放声音按钮的网页,使用HTML5音频标记。但我注意到触摸事件和声音之间的显著延迟正在播放,音频文件已经被缓存甚至之后。我想,这可能是由于iOS的Safari浏览器处理声音的方式,但我不知道。是否有任何解决方案或创造性的方法可以解决该问题?我怎样才能尽量减少触摸事件和播放之间的延迟?

I'm developing a mobile web app using HTML5 & Javascript. The goal is to have a page with buttons that play sound after touch events, using the HTML5 audio tag. But I'm noticing a significant delay between the touch event and the sound being played, even after the audio file has been cached. I think this may be due to the way iOS Safari handles sound but I'm not sure. Are there any solutions or creative workarounds to this issue? How can I minimize the delay between the touch event and playback?

推荐答案

音频延迟可能是因为在iOS中,由于移动数据收费有缓冲的问题。用户必须明确地触发事件,以便为内容来启动下载。

The audio delay may be because of buffering issues in iOS that are there due to cellular data charges. The user has to explicitly trigger the event in order for the content to start being downloaded.

在野生iOS上​​(对于所有设备,包括ipad公司),其中用户可以是蜂窝网络中,每个数据单元被充电,preLOAD和自动播放被禁止。没有数据加载,直到用户启动它。这意味着JavaScript的play()和load()的方法也没有改变,直到用户启动播放,除非play()或load()方法是由用户操作触发。换句话说,用户启动的播放按钮的作品,但在onload =播放()事件不会。

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.

- <一href=\"https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW1\" rel=\"nofollow\">https://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Device-SpecificConsiderations/Device-SpecificConsiderations.html#//apple_ref/doc/uid/TP40009523-CH5-SW1

===编辑===

一个潜在的改进是使用较低的比特率/高COM pressed音频的移动产品。质量会然而,可以显著降低。只使用如果它在你的应用程序可以接受的。

One potential improvement is to use lower bitrate/ higher compressed audio for mobile products. The quality will, however, be significantly reduced. Use only if it is acceptable in your application.

这篇关于在HTML5移动网络应用程序音频延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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