Jplayer音频从头开始重新开始

时间:2017-09-20 19:57:45

标签: javascript html5-audio jplayer icecast

当尝试通过我们网站上的jplayer插件播放静态音频内容时,音频将在1.5到2分钟后重新开始,并继续反复播放。

它只发生在iOS产品中。我设置了一个网络表单,遇到任何播放问题的人可以通过几个字段填写它,询问他们使用的是什么技术。到目前为止,100%的回复来自使用Apple产品的人。这与我尝试复制问题的经验相关。虽然有人抱怨并说他在iMac上,但我已经测试了两台macBook并且工作正常。

你可以在这里听一听:http://kansaspublicradio.org/blog/dan-skinner/conversations-gordon-lafer-one-percent-solution(如果你使用的是Chrome,你需要启用Flash - 这是我正在处理的另一个问题,我不认为它们是相关的)

但是,我们在这些设备上运行的应用程序不会发生这种情况,所以我们认为这不是我们的音频服务器的问题 - 这是Icecast。是的,我们正在为流式音频服务器上的静态音频文件提供服务。

这是我的jPlayer代码:

    jQuery(document).ready(function($){

      var theSolution = "html,flash"; // use HTML5 or flash?

      // we need to find if it's Chrome or not because HTML5 + icecast is not working in chrome
      // see: http://stackoverflow.com/questions/4565112/javascript-how-to-find-out-if-the-user-browser-is-chrome/13348618#13348618
      var isChromium = window.chrome,
          winNav = window.navigator,
          vendorName = winNav.vendor,
          isOpera = winNav.userAgent.indexOf("OPR") > -1,
          isIEedge = winNav.userAgent.indexOf("Edge") > -1,
          isIOSChrome = winNav.userAgent.match("CriOS");

      if(isIOSChrome){
         // is Google Chrome on IOS
         theSolution = "html,flash";
         console.log('is google chrome on iOS');
      } else if(isChromium !== null && isChromium !== undefined && vendorName === "Google Inc." && isOpera == false && isIEedge == false) {
         // is Google Chrome
         theSolution = "flash,html";
         console.log('is google chrome');
      } else { 
         // not Google Chrome 
         theSolution = "html,flash";
         console.log('is NOT google chrome');
      }

      $("#kpr_jplayer-1").jPlayer({
        ready: function () {
          $(this).jPlayer("setMedia", {
            mp3: "http://streaming.kansaspublicradio.org:8000/mp3/First_9665638.mp3",
          });
        },
        swfPath: "/sites/all/libraries/jplayer",
        supplied: "mp3",
        play: function() { 
            // To avoid multiple jPlayers playing together.
            $(this).jPlayer("pauseOthers");
        },
        cssSelectorAncestor: "#jp_container_1",
        wmode: "window",
        globalVolume: true,
        useStateClassSkin: true,
        autoBlur: false,
        smoothPlayBar: true,
        keyEnabled: true,
        preload: "auto",
        solution: theSolution, // see above
      });
    });

为什么这样做?我该怎么做才能解决它?

0 个答案:

没有答案
相关问题