2013-11-05 219 views
0

我無法使用jPlayer播放.flv文件的視頻文件。jPlayer無法播放.flv文件

我從jPlayer主頁下載演示代碼並嘗試編輯一個演示文件來播放.flv文件。

下面是代碼:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset=utf-8 /> 

<!-- Website Design By: www.happyworm.com --> 
<title>Demo : jPlayer as a video player</title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
<link href="skin/blue.monday/jplayer.blue.monday.css" rel="stylesheet" type="text/css" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 
<script type="text/javascript" src="js/jquery.jplayer.min.js"></script> 
<script type="text/javascript"> 
//<![CDATA[ 
$(document).ready(function(){ 

    $("#jquery_jplayer_1").jPlayer({ 
     ready: function() { 
      $(this).jPlayer("setMedia", { 
       flv: "http://stream.baicadicungnamthang.info/medias/Ngoc%20Lan%202/Bai%20ca%20thong%20nhat%20-%20(Vo%20Van%20Di)%20-%20Ngoc%20Lan.flv" 
      }); 
     }, 
     swfPath: "js", 
     supplied: "flv, webmv, ogv, m4v", 
     size: { 
      width: "640px", 
      height: "360px", 
      cssClass: "jp-video-360p" 
     }, 
     smoothPlayBar: true, 
     keyEnabled: true 
    }); 

}); 
//]]> 
</script> 
</head> 
<body> 
     <div id="jp_container_1" class="jp-video jp-video-360p"> 
      <div class="jp-type-single"> 
       <div id="jquery_jplayer_1" class="jp-jplayer"></div> 
       <div class="jp-gui"> 
        <div class="jp-video-play"> 
         <a href="javascript:;" class="jp-video-play-icon" tabindex="1">play</a> 
        </div> 
        <div class="jp-interface"> 
         <div class="jp-progress"> 
          <div class="jp-seek-bar"> 
           <div class="jp-play-bar"></div> 
          </div> 
         </div> 
         <div class="jp-current-time"></div> 
         <div class="jp-duration"></div> 
         <div class="jp-controls-holder"> 
          <ul class="jp-controls"> 
           <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li> 
           <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li> 
           <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li> 
           <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li> 
           <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li> 
           <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li> 
          </ul> 
          <div class="jp-volume-bar"> 
           <div class="jp-volume-bar-value"></div> 
          </div> 
          <ul class="jp-toggles"> 
           <li><a href="javascript:;" class="jp-full-screen" tabindex="1" title="full screen">full screen</a></li> 
           <li><a href="javascript:;" class="jp-restore-screen" tabindex="1" title="restore screen">restore screen</a></li> 
           <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li> 
           <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li> 
          </ul> 
         </div> 
         <div class="jp-title"> 
          <ul> 
           <li>Big Buck Bunny Trailer</li> 
          </ul> 
         </div> 
        </div> 
       </div> 
       <div class="jp-no-solution"> 
        <span>Update Required</span> 
        To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>. 
       </div> 
      </div> 
     </div> 
</body> 

</html> 

這裏的視頻文件是正確的,你可以對其進行測試。 http://stream.baicadicungnamthang.info/medias/Ngoc%20Lan%202/Bai%20ca%20thong%20nhat%20-%20(Vo%20Van%20Di)%20-%20Ngoc%20Lan.flv

但是玩家不能玩它。

任何人都可以看我可以播放.flv文件的演示嗎?

更新:當使用調試模式errorAlerts: true,,它顯示了這個警告: enter image description here

更新:我已經找到了解決辦法 只需編輯從

supplied: "flv, webmv, ogv, m4v", 

supplied: "flv", 
+0

試試這個http://stackoverflow.com/questions/10786034/how-play-flv-files-using-jplayer。如果這有效,告訴我,我可以添加這個答案。謝謝! –

+0

@EliteGamer:我試過了你的建議,但我仍然不適合我。它顯示了與上面更新相同的錯誤。 –

+0

讓我看看我還能做些什麼來解決這個問題。 –

回答

0

我找到了這個代碼的解決方案:

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

    $('body').append('<div id="mediaplayer"></div>'); 
    $.getScript('http://player.longtailvideo.com/jwplayer.js', function() 
    { 
     jwplayer("mediaplayer").setup({ 
     flashplayer: "http://player.longtailvideo.com/player.swf", 
     file: 'http://stream.baicadicungnamthang.info/medias/Ngoc%20Lan%202/Bai%20ca%20thong%20nhat%20-%20(Vo%20Van%20Di)%20-%20Ngoc%20Lan.flv', 
    autostart: "true" 
    }); 
     $('#mediaplayer_wrapper').css('z-index','107').css('width','853px').css('height','505px').css('padding','10px').addClass('bg_one').center(); 
    }); 

}); 

您將需要調整代碼,以符合您的規格,但這完美地工作。

+0

感謝您的解決方案,但這只是一個臨時解決方案。該方法使用Flash播放器播放不具有HTML5特徵的視頻。我需要一個適用於上述規格的解決方案。 –

0

我已經找到了解決辦法:這很簡單:

supplied: "flv, webmv, ogv, m4v", 

只需編輯

supplied: "flv", 

這裏的規則是:在setMediasupplied必須匹配。在我的原始代碼 setMedia字段中,我只定義了一種媒體類型(flv),但在提供的字段中,我定義了四種媒體類型(flv,webmv,ogv,m4v)。所以它制定了規則,jPlayer無法播放它。

馬克Panaghiston解決辦法:

一個簡單的問題,提供 : 「FLV」

你有它的方式,以 「M4V,FLV」 你必須提供這兩種格式都在setMedia中。這就是爲什麼在大多數瀏覽器上,例如Chrome, 都會設置HTML解決方案並期待m4v網址。那麼你只有 給flv,所以你打破了規則,jPlayer不能播放它。

如果你說我會提供格式A,B和C,那麼你必須爲每個setMedia提供它們。>核心格式在文檔中給出: http://jplayer.org/latest/developer-guide/#jPlayer-essential-formats

例外是媒體播放器,您提供:audio-A,audio-B,video-A,video-B,然後setMedia必須給予所有的 音頻ro視頻格式,以確保它的工作。

你還有其他問題,雖然...你是不是使用絕對URL。 - 我最近在Github上修復了這個問題,並計劃推出 。

參見: http://jplayer.org/latest/developer-guide/#jPlayer-option-supplied http://jplayer.org/latest/developer-guide/#jPlayer-setMedia

最終在你的情況,你應該放棄的FLV格式並只能使用M4V(MP4:H.264/AAC)格式。 FLV格式是副產品,並且從未成爲設計的預期部分。