jqueryui插件的音效
我正在使用jQuery UI插件,希望在动画发生时有相应的音效。我怎么可能做到呢? 这是它的HTML和脚本jqueryui插件的音效,jquery,jquery-ui,Jquery,Jquery Ui,我正在使用jQuery UI插件,希望在动画发生时有相应的音效。我怎么可能做到呢? 这是它的HTML和脚本 $('img').click(function() { $('img') .animate({left: '400px', top: '400px'}, 3000, "easeInOutQuad") .animate({left: '-=400px', top: '-=400px', opacity: 0}, 3000, "easeInCub
$('img').click(function() {
$('img')
.animate({left: '400px', top: '400px'}, 3000, "easeInOutQuad")
.animate({left: '-=400px', top: '-=400px', opacity: 0}, 3000, "easeInCubic");
});
使用html5音频
var audio = new Audio('audio_file.mp3');
$('img').click(function() {
audio.play();
$('img')
.animate({left: '400px', top: '400px'}, 3000, "easeInOutQuad")
.animate({left: '-=400px', top: '-=400px', opacity: 0}, 3000, "easeInCubic");
});
我如何控制play()函数,比如说,让它不停地播放,或者在几毫秒后暂停播放?您可以在此处找到有关javascript媒体对象的更多信息:。您可以执行类似于设置超时的操作(函数(){audio.pause();audio.currentTime=0;},500);对于autoplay,您可能可以绑定到
结束的
回调,并在那里执行audio.play()
。从来没有做过,但它应该会起作用。