Javascript重复音频 [英] Javascript Repeating Audio
本文介绍了Javascript重复音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直试图让这个JavaScript在完成后重复音频,我浏览了一下,并且对JavaScript没有经验,尽管我已经尝试调整并研究到目前为止我没有运气。 / p>
我会非常感谢任何帮助和提示
非常感谢 - Grant
<! - 内部脚本 - >
<! - 音频播放器 - >
< script>
$(document).ready(function(){
var audioElement = document.createElement('audio');
audioElement.setAttribute('src','music / audio.mp3' );
audioElement.setAttribute('play','autoplay');
//audioElement.load()$ b $ .get();
audioElement.addEventListener(load ),函数(){
audioElement.play();
audioElement.loop();
},true);
$(' ('。pause')。click(function(){
audioElement.play();
});
$ b $('。pause')。click函数(){
audioElement.pause();
});
});
< / script>
< div class =play> Play< / div>
< div class =pause>停止< / div>
解决方案
设置重复曲目的循环属性:
audioElement.loop = true
I have been trying to get this JavaScript to repeat the audio once it has finished, I have had a look around and I am inexperienced with JavaScript, although I have made attempts tweaking and researching I have had no luck so far.
I would be very grateful for any help and tips
Many thanks- Grant
<!-- Script inside body -->
<!-- Audio Player -->
<script>
$(document).ready(function() {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', 'music/audio.mp3');
audioElement.setAttribute('play', 'autoplay');
//audioElement.load()
$.get();
audioElement.addEventListener("load", function() {
audioElement.play();
audioElement.loop();
}, true);
$('.play').click(function() {
audioElement.play();
});
$('.pause').click(function() {
audioElement.pause();
});
});
</script>
<div class="play">Play</div>
<div class="pause">Stop</div>
解决方案
Set loop property for repeat track:
audioElement.loop = true
这篇关于Javascript重复音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文