有没有办法在 jPlayer 中进行音频淡出
Is there a way for audio fadeout in jPlayer
功能:
我已经实现了一个 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 developed by Solutions Nitriques
备选方案:
现在,我不相信以下代码:我在 [google 群组论坛] 上找到它(它发布于 2009 年)3 There was an alternative suggestion on metafilters google 上的人小组确实强调要确保音量尚未为 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);
}
});
功能:
我已经实现了一个 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 developed by Solutions Nitriques
备选方案:
现在,我不相信以下代码:我在 [google 群组论坛] 上找到它(它发布于 2009 年)3 There was an alternative suggestion on metafilters google 上的人小组确实强调要确保音量尚未为 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);
}
});