Use and Problems of Player JPlayer

Original address: http://blog.csdn.net/z69183787/article/details/8178656?_t_t=0.5149982699228508

jPlayer is used to control and play mp3 files jQuery Plug-in unit. It uses Flash to play mp3 files in the background and XHML/CSS can be used to customize the appearance of the front player. Support:

One thing that's better is that it's in support. HTML5 The browser will use html5 Label audio or video, but unsupported browsers use swf to play

Select the Mp3 file you want to play.

Play, pause, stop control.
Volume control.  

Get information about playback progress, etc.

Official website: http://www.jplayer.org/

Support format:

  • HTML5: mp3, mp4 (AAC/H.264), ogg (Vorbis/Theora), webm (Vorbis/VP8), wav
  • Flash: mp3, mp4 (AAC/H.264), flv

Example:

  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <meta charset=utf-8 />  
  5.   
  6. <!-- Website Design By: www.happyworm.com -->  
  7. <title>Demo : jPlayer as a video player</title>  
  8. <link href="skin/blue.monday/jplayer.blue.monday.css" rel="stylesheet" type="text/css" />  
  9. <script type="text/javascript" src="js/jquery-1.7.1.js"></script>  
  10. <script type="text/javascript" src="js/jquery.jplayer.min.js"></script>  
  11. <script type="text/javascript">  
  12. //<![CDATA[ 
  13. $(document).ready(function(){ 
  14.  
  15.     $("#jquery_jplayer_1").jPlayer({ 
  16.         ready: function () { 
  17.             $(this).jPlayer("setMedia", { 
  18.                 flv: "/workflowLocal/j/1.flv" 
  19.             }); 
  20.         }, 
  21.         swfPath: "js", 
  22.         supplied: "flv", 
  23.         size: { 
  24.             width: "640px", 
  25.             height: "360px", 
  26.             cssClass: "jp-video-360p" 
  27.         } 
  28.     }); 
  29.  
  30. }); 
  31. function a(){ 
  32.         $("#jquery_jplayer_1").jPlayer("setMedia", { 
  33.                 flv: "/workflowLocal/j/2.flv" 
  34.             }); 
  35.     } 
  36. //]]>  
  37. </script>  
  38. </head>  
  39. <body>  
  40.         <input type="button" onclick="a();">  
  41.         <div id="jp_container_1" class="jp-video jp-video-360p">  
  42.             <div class="jp-type-single">  
  43.                 <div id="jquery_jplayer_1" class="jp-jplayer"></div>  
  44.                 <div class="jp-gui">  
  45.                     <div class="jp-video-play">  
  46.                         <a href="javascript:;" class="jp-video-play-icon" tabindex="1">play</a>  
  47.                     </div>  
  48.                     <div class="jp-interface">  
  49.                         <div class="jp-progress">  
  50.                             <div class="jp-seek-bar">  
  51.                                 <div class="jp-play-bar"></div>  
  52.                             </div>  
  53.                         </div>  
  54.                         <div class="jp-current-time"></div>  
  55.                         <div class="jp-duration"></div>  
  56.                         <div class="jp-controls-holder">  
  57.                             <ul class="jp-controls">  
  58.                                 <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>  
  59.                                 <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>  
  60.                                 <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>  
  61.                                 <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>  
  62.                                 <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>  
  63.                                 <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>  
  64.                             </ul>  
  65.                             <div class="jp-volume-bar">  
  66.                                 <div class="jp-volume-bar-value"></div>  
  67.                             </div>  
  68.                             <ul class="jp-toggles">  
  69.                                 <li><a href="javascript:;" class="jp-full-screen" tabindex="1" title="full screen">full screen</a></li>  
  70.                                 <li><a href="javascript:;" class="jp-restore-screen" tabindex="1" title="restore screen">restore screen</a></li>  
  71.                                 <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>  
  72.                                 <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>  
  73.                             </ul>  
  74.                         </div>  
  75.                         <div class="jp-title">  
  76.                             <ul>  
  77.                                 <li>shentong metro</li>  
  78.                             </ul>  
  79.                         </div>  
  80.                     </div>  
  81.                 </div>  
  82.                 <div class="jp-no-solution">  
  83.                     <span>Update Required</span>  
  84.                     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>.  
  85.                 </div>  
  86.             </div>  
  87.         </div>  
  88. </body>  
  89.   
  90. </html>  
Most of them are demo s on official websites. They need to introduce jquery.jplayer.min.js, two css packages on official websites, and Jplayer.swf.

The catalogue structure is as follows. js js file provided for official website in folder, css skin package provided by skin for official website


There are two strange problems here, when you're at home. test demo, can only play the official website said m4v format, but not with flv format, but on the server to solve.

The other is

  1. ready: function () {  
  2.             $(this).jPlayer("setMedia", {  
  3.                 flv: "/workflowLocal/j/1.flv"  
  4.             });  
  5.         },  
When setMedia sets file paths here, only url paths such as http://xxxxxxxxxxxxx can be referenced locally, instead of absolute or relative paths.

On the server, absolute paths can be used, but absolute paths must start with the project root directory.

These two problems don't know how to solve...

Because the function of switching video is used in the project, I tried the following code, click the button to switch.

  1. function a(){  
  2.         $("#jquery_jplayer_1").jPlayer("setMedia", {  
  3.                 flv: "/workflowLocal/j/2.flv"  
  4.             });  
  5.     }  

The effect of playback on the server is as follows:



Keywords: Javascript JQuery html5

Added by stuffradio on Wed, 29 May 2019 23:55:27 +0300