0
我有一個免費的插件AV上 http://ionden.com/a/plugins/ion.sound/en.htmlIon.Sound 1.1.0 JQuery的JavaScript的效應初探
我當前的JavaScript代碼看起來像這樣
(function ($) {
if($.ionSound) {
return;
}
var settings = {},
soundsNum,
canMp3,
url,
i,
sounds = {},
playing = false;
var createSound = function(name){
sounds[name] = new Audio();
canMp3 = sounds[name].canPlayType("audio/mp3");
if(canMp3 === "probably" || canMp3 === "maybe") {
url = settings.path + name + ".mp3";
} else {
url = settings.path + name + ".ogg";
}
$(sounds[name]).prop("src", url);
sounds[name].load();
sounds[name].volume = settings.volume;
};
var playSound = function(name){
var $sound = sounds[name],
playingInt;
if(typeof $sound === "object" && $sound !== null) {
if(!settings.multiPlay && !playing) {
$sound.play();
playing = true;
playingInt = setInterval(function(){
if($sound.ended) {
clearInterval(playingInt);
playing = false;
}
}, 250);
} else if(settings.multiPlay) {
if($sound.ended) {
$sound.play();
} else {
try {
$sound.currentTime = 0;
} catch (e) {}
$sound.play();
}
}
}
};
$.ionSound = function(options){
settings = $.extend({
sounds: [
"water_droplet"
],
path: "static/sounds/",
multiPlay: true,
volume: "0.5"
}, options);
soundsNum = settings.sounds.length;
if(typeof Audio === "function" || typeof Audio === "object") {
for(i = 0; i < soundsNum; i += 1){
createSound(settings.sounds[i]);
}
}
$.ionSound.play = function(name) {
playSound(name);
};
};
$.ionSound.destroy = function() {
for(i = 0; i < soundsNum; i += 1){
sounds[settings.sounds[i]] = null;
}
soundsNum = 0;
$.ionSound.play = function(){};
};
}(jQuery的))問題;
我的問題是聲音觸發慢(間隔響應)是否有人知道這可以設置/創建響應像1秒或更長時間即使點擊一個按鈕我需要,如果用戶點擊以加快聲音沒有足夠快的反應