我正在制作一个应用程序来播放声音片段,但是当我尝试播放它们时脚本会卡住(两个片段是重复的!) 这是我的剧本:
<script type="text/javascript">
var playerObj = null;
function SoundA() {
droid.stopSound(playerObj);
droid.playSound(true);
if (playerObj == null) {
playerObj = droid.playSound('www/res/15000.mp3', true);
} else {
if (droid.isPlayingSound(playerObj)) {
droid.stopSound(playerObj);
}
playerObj = null;
}
}
function SoundB() {
droid.stopSound(playerObj);
droid.playSound(true);
if (playerObj == null) {
playerObj = droid.playSound('www/res/18000.mp3', true);
} else {
if (droid.isPlayingSound(playerObj)) {
droid.stopSound(playerObj);
}
playerObj = null;
}
}
</script>
按钮按以下方式调用。
<button onclick="SoundA()">15k</button>
<button onclick="SoundB()">17k</button>