功能:
我已经实现了jPlayer音频功能,其中音频将根据视频播放。
因此,在视频的某个部分,我需要将音频设置为逐渐淡出,而不是突然静音。
我做了什么:
我已经将jplayer设置为播放以下视频列表,并且还在以下参数中将音频设置为静音:$("#Macallan_Video").jPlayer("mute", true);
问题:
音频将在视频的所需部分静音。但是,通过查看jPlayer的文档,我仍然无法将jplayer音频设置为淡出。
我可以在淡出音频方面获得一些帮助。
码:
function stop_interrupt() {
isInterrupt = false;
triggerFeedback = "0";
$("#M_Video").jPlayer("mute", true);
console.log("stop_interrupt triggerFeedback: " + triggerFeedback);
}
//To continuously play a list of video
$("#M_Video").jPlayer({
ready: function() {
console.log("currentPlaying " + videoList[videoIndex]);
$("#M_Video").jPlayer("setMedia", {
m4v: videoList[videoIndex]
}).jPlayer("play");
stop_interrupt();
},
ended: function() {
videoIndex++;
console.log("NewCurrent:" + videoIndex);
console.log("current :" + videoList[videoIndex]);
if (videoIndex >= videoList.length) {
console.log("Next" + videoIndex);
videoIndex = 0;
}
$("#M_Video").jPlayer("setMedia", {
m4v: videoList[videoIndex]
}).jPlayer("play");
stop_interrupt();
},
swfPath: "javascript",
muted: true,
loop: true,
supplied: "webmv, ogv, m4v",
size: {
width: 1400,
height: 750
}
});
$("#M_Video").show();
function show_interrupt(flag) {
//Set Timeout for flag to be equal to "1"
if (flag == "1") {
$("#M_Video").jPlayer("mute", false);
}
}
最佳答案
最佳解决方案:下载jquery jplayer fade plugin from github开发的Solutions Nitriques
备择方案:
现在,我对以下代码一无所知:我在[google groups论坛](于2009年发布)上找到了它。3 metafilters上还有其他建议。为0(有意义!)。这是代码。
var vol = 20;
var t = 0;
function playSample(id) {
$("#player").stop();
vol = 20;
stopSample();
$("#player").setFile("yourfile.mp3");
fadeIn();
$("#player").play();
}
function stopSample(id, fadeout) {
clearTimeout(t);
//Set fadeout = true in the function call: <a href="#"
onClick="stopSample(23, true);">Stop</a>
if(fadeout == true) {fadeOut();}
}
$("#player").jPlayer({
swfPath: "swfpath";
});
$("#player").onSoundComplete(function() {
stopSample();
});
function fadeIn() {
if(vol < 150) {
$("#player").volume(vol);
t = setTimeout("fadeIn()", 200);
vol = vol + 10;
} else {
clearTimeout(t);
vol = 150;
}
}
function fadeOut() {
if(vol > 0) {
$("#player").volume(vol);
t = setTimeout("fadeOut()", 200);
vol = vol - 10;
} else {
clearTimeout(t);
$("#player").stop();
vol = 20;
}
}
$("#player").onProgressChange(function (l,pr,pa,pt,t) {
if(pa > 90 && pa < 92) {
stopSample(0, true);
}
});
关于javascript - jPlayer中是否有音频淡入的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37529789/