【问题标题】:Is there a way for audio fadeout in jPlayerjPlayer中是否有音频淡出的方法
【发布时间】:2016-05-30 16:00:20
【问题描述】:

功能:

我已经实现了一个 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);
   }
 }

【问题讨论】:

    标签: javascript jquery audio jplayer


    【解决方案1】:

    最佳解决方案:下载Solutions Nitriques开发的jquery jplayer fade plugin from github

    替代方案:

    现在,我不相信以下代码:我在 [google groups forum] 上找到它(发布于 2009 年)3metafilters 有一个替代建议@ google groups 上的那个人确实强调确保音量尚未为 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); 
          } 
        }); 
    

    【讨论】:

      猜你喜欢
      • 2010-09-07
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多