Answers
<div class="play">Play</div>
<script>
$(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'audio.mp3');
audioElement.setAttribute('autoplay', 'autoplay');
//audioElement.load()
$.get();
audioElement.addEventListener("load", function() {
audioElement.play();
}, true);
$('.play').click(function() {
audioElement.play();
});
});
</script>
Mio-L
answered 10 years, 3 months ago
梯子自备 google - js html5 audio
参考这个 https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video
我这边没梯子,具体实现stackoverflow上一定有
但我之前做过一个游戏,用过html音频,你要保证音频足够小,触发的时候会有加载延迟,你可以考虑页面加载的时候就把音频加载进来
BTW:弹窗还要音频?我就不想说啥了
沙包你妹啊
answered 10 years, 3 months ago