如何使用php每1或2分钟播放一个声音
当用户在页面中输入第一个声音播放时
1分钟后,将播放另一个声音,第一个声音将停止当然,所有这些都将自动播放
html5代码:
<audio controls autoplay>
<source src="horse.mp3" type="audio/mpeg">
</audio>
您可以简单地将声音与计时合并,并像这样实现:
<audio controls="controls" onloadeddata="audioSoundFunction()">
<source src="horse.mp3" type="audio/mp3" />
</audio>
Javascript:
function audioSoundFunction() {
var audioSound = this;
setTimeout(function() {
audioSound.play();
}, 10000)
}
<audio id="selecterForAudio" controls autoplay>
<source src="horse.mp3" type="audio/mpeg">
</audio>
javascript/jquery
var myVar = setInterval(myTimer, 60000);
var audio = $("#selecterForAudio")[0];
var counter = 0;
var musicfiles = ["horse.mp3", "lard.mp3"];
function myTimer(){
//stopping the audio
audio.stop();
//setting new source of array of sources
$('#selecterForAudio').find('source').attr('src',musicfiles[counter]);
counter+1;
if(counter>COUNT(musicfiles)){
counter=0;
}
//play sound
audio.play();
}
这样的东西应该适合你的需求-它可能需要一点花呢通过