我目前使用在 javascript 中生成的 html5 dom 内容在网页中播放一些声音。
在 firefox 和 google chrome 浏览器中没有问题,一切正常,但在 android 设备上我听不到声音(即使我使用 google chrome mobile)。
我使用 ogg vorbis 内容(我的 android 设备支持它,就像 w3schools 报告的那样,“是否支持”网站也是如此,根据我对音频标签播放的测试。) 我的所有功能都被正确调用(console.log 和警报测试已经完成),我的设备上的所有输出都启用了声音,并且当我启动音频元素时,音频标签的所有功能都具有很好的值(value):
a.readyState => 4
a.currentSrc => right url
a.error => null
a.volume => 1
你听说过类似的问题吗?
提前致谢。
链接: 我的申请:http://ci.worldheberg.com/test.html 我的 JavaScript 脚本:http://ci.worldheberg.com/test.js 资料来源: 已编辑(不能发布超过 2 个链接)
相关代码:
//attente 是一个数组,其中包含每个音频部分启动前的时间
function playSound() {
"use strict";
console.log("play sound fonction");
var actuel, i, fonction;
actuel = -1;
fonction = function () {
actuel++;
console.log(a = audios[actuel]);
/*alert(a.readyState);
alert(a.currentSrc);
alert(a.error);
alert(a.volume);*/
a.volume = 1;
a.play();
};
for (i = 0; i < audios.length; i++) {
alert(attente[i]);
window.setTimeout(
fonction,
(attente[i])
);
}
}
最佳答案
好的
经过多次尝试,我终于找到了问题所在。
对于所有遇到相同问题的人,请检查您的采样频率是否为 44100 Hz(我没有在任何地方看到此信息,但尝试过,...) chrome for computer 支持更多的频率,但默认的 android 浏览器和 chrome mobile 不支持更高的频率。
我希望我的经验能用于其他人。
非常感谢所有看到此消息的人(我在 3 天多前就遇到了这个错误)
关于javascript - android 设备上的 html5 音频标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16509096/