我在我的HTML页面中使用了声音,并编写了JavaScript函数在特定时间播放。问题是,当我在PC中加载页面时,它运行良好,但在移动设备上,声音无法播放。哪里不对?声音不能在手机上播放
<audio id="buzzer" controls="controls">
<source src="assets/sound/buzzer.mp3" type="audio/mpeg" />
function PlaySound1() {
var audioElement = document.getElementById('buzzer');
audioElement.setAttribute("preload", "auto");
audioElement.autobuffer = true;
var source1 = document.createElement('source');
source1.type= 'audio/mpeg';
source1.src= 'buzzer.mp3';
audioElement.appendChild(source1);
audioElement.load();
audioElement.play();
};
你是什么意思的手机? iPhone,Android,Blackberry等?哪个浏览器? –
android和iphone –
移动音频需要用户交互才能启动。什么叫PlaySound1? –