我有一个脚本,在倒计时后应播放.ogg文件。鉴于文件的大小,倒计时结束后应播放的文件大约为16kb。现在脚本看起来很好并且在桌面浏览器上运行良好,但它不会在我的Android设备上播放16kb ogg文件。我无法弄清楚可能是什么问题。还有另一个ogg文件播放onClick并且它在Android浏览器上播放没有任何问题,所以我不认为文件格式是这样的。请检查代码。
var clickTimer;
$("#startClock").click( function(){
var pose = document.getElementById("pose");
if (clickTimer) {
clearInterval(clickTimer);
}
var counter = document.getElementById('minutes').value;
clickTimer = setInterval(function() {
counter--;
if (counter >= 0) {
span = document.getElementById("count");
span.innerHTML = counter;
}
if (counter === 0) {
span = document.getElementById("count");
pose.play();
}
}, 1000);
});

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js?ver=4.1'></script>
<audio id="pose" src="https://dl.dropboxusercontent.com/u/38489556/changepose.ogg" ></audio>
<div id="count">0</div>
<div id="min">Mins</div>
<select id="minutes">
<option value="6" selected="selected">1</option>
</select>
<button id=startClock >Start</button>
&#13;
答案 0 :(得分:0)
我已经找到了解决方法。如果有人遇到类似的问题,下面是带有更改的代码。
var clickTimer;
$("#startClock").click( function(){
var pose =
document.getElementById("pose").play();
document.getElementById("pose").pause();
if (clickTimer) {
clearInterval(clickTimer);
}
var counter = document.getElementById('minutes').value;
clickTimer = setInterval(function() {
counter--;
if (counter >= 0) {
span = document.getElementById("count");
span.innerHTML = counter;
}
if (counter === 0) {
span = document.getElementById("count");
document.getElementById("pose").play();
}
}, 1000);
});
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js?ver=4.1'></script>
<audio id="pose" src="https://dl.dropboxusercontent.com/u/38489556/changepose.ogg" ></audio>
<div id="count">0</div>
<div id="min">Mins</div>
<select id="minutes">
<option value="6" selected="selected">1</option>
</select>
<button id=startClock >Start</button>
感谢您的时间!