gpt4 book ai didi

javascript - HTML5 移动网络应用程序的音频延迟

转载 作者:行者123 更新时间:2023-11-28 20:12:12 24 4
gpt4 key购买 nike

我正在使用 HTML5 和 Javascript 开发移动网络应用程序。目标是使用 HTML5 音频标签创建一个带有按钮的页面,该按钮在触摸事件发生后播放声音。但是我注意到触摸事件和正在播放的声音之间存在明显的延迟,即使在缓存音频文件之后也是如此。我认为这可能是由于 iOS Safari 处理声音的方式所致,但我不确定。此问题是否有任何解决方案或创造性的解决方法?如何最小化触摸事件和播放之间的延迟?

最佳答案

音频延迟可能是由于 iOS 中因蜂窝数据收费而导致的缓冲问题。用户必须明确触发事件才能开始下载内容。

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#//apple_ref/doc/uid/TP40009523-CH5-SW1

=== 编辑 ===

一个潜在的改进是为移动产品使用较低的比特率/较高的压缩音频。但是,质量将大大降低。仅在您的应用程序可接受时使用。

关于javascript - HTML5 移动网络应用程序的音频延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19778277/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com