如何在JavaScript中播放声音

编程入门 行业动态 更新时间:2024-10-22 15:29:10
本文介绍了如何在JavaScript中播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下内容:

<audio id="clickdown-wav" src="ClickDown.wav" preload="auto"></audio>

,然后在我的JavaScript,我有:

and then in my JavaScript, I have:

var ClickDown = $('#clickdown-wav')[0]; $(document).delegate('a','click',function() { ClickDown.play(); });

问题是,这不是太活泼的(在iPad上),因为我preSS锚标记。有时间我preSS锚标记和WAV文件播放之间有明显的滞后。

The problem is that it's not too snappy (on an iPad) as I press anchor tags. There is a noticeable lag between the time I press the anchor tag and the wav file plays.

问:是否有来源$ C ​​$ C唯一的解决方案,以从​​JavaScript播放声音?Clickdown.wav只有1K。

Q: Is there a source code only solution to playing sounds from JavaScript? Clickdown.wav is only 1k.

推荐答案

在iOS上,没有preloading。这是由苹果进行有目的的,以使用户将不必使用不必要的带宽

On iOS, there is no preloading. This was done by Apple on purpose, so that the user wouldn't have to use unnecessary bandwidth.

更多推荐

如何在JavaScript中播放声音

本文发布于:2023-11-14 15:12:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587733.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声音   如何在   JavaScript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!