jquery+jplayer实现歌词同步的mp3音乐播放器效果

时间:2020-12-31 10:15:26

jquery+jplayer实现歌词同步的mp3音乐播放器效果

 

 


实例代码下载

Java代码  jquery+jplayer实现歌词同步的mp3音乐播放器效果
  1. <div class="container">  
  2.             <div class="demo">  
  3.                 <textarea id="lrc_content" name="textfield" cols="70" rows="10" style="display: none;">   
  4. [00:03.00]洋葱  
  5. [00:06.00]演唱:平安  
  6. [00:09.00]  
  7. [00:11.38]如果你眼神能够为我片刻的降临  
  8. [00:21.23]如果你能听到心碎的声音  
  9. [00:28.88]盘底的洋葱像我永远是配角戏  
  10. [00:35.74]偷偷的看着你偷偷的隐藏着自己  
  11. [00:43.48]  
  12. [00:44.90]如果你愿意一层一层  
  13. [00:48.46]一层的剥开我的心  
  14. [00:52.66]你会发现你会讶异  
  15. [00:56.40]你是我最压抑最深处的秘密  
  16. [01:00.26]如果你愿意一层一层  
  17. [01:03.69]一层的剥开我的心  
  18. [01:07.76]你会鼻酸你会流泪  
  19. [01:11.60]只要你能听到我看到我的全心全意  
  20. [01:18.30]  
  21. [01:19.11]如果你愿意一层一层  
  22. [01:22.57]一层的剥开我的心  
  23. [01:26.66]你会发现你会讶异  
  24. [01:30.41]你是我最压抑最深处的秘密  
  25. [01:34.48]如果你愿意一层一层  
  26. [01:37.58]一层的剥开我的心  
  27. [01:41.51]你会鼻酸你会流泪  
  28. [01:45.15]只要你能听到我看到我的全心全意  
  29. [01:53.55]  
  30. [01:55.65]你会鼻酸你会流泪  
  31. [01:59.84]只要你能听到我看到我的全心全意  
  32. [02:12.57] www.w2bc.com  
  33.                 </textarea>  
  34.                 <div class="music_box">  
  35.                     <div id="jquery_jplayer_1" class="jp-jplayer">  
  36.                     </div>  
  37.                     <div id="jp_container_1" class="jp-audio">  
  38.                         <div class="jp-type-single">  
  39.                             <div class="jp-gui jp-interface">  
  40.                                 <ul class="jp-controls">  
  41.                                     <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>  
  42.                                     <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>  
  43.                                     <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>  
  44.                                     <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>  
  45.                                     <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>  
  46.                                     <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>  
  47.                                 </ul>  
  48.                                 <div class="jp-progress">  
  49.                                     <div class="jp-seek-bar">  
  50.                                         <div class="jp-play-bar">  
  51.                                         </div>  
  52.                                     </div>  
  53.                                 </div>  
  54.                                 <div class="jp-volume-bar">  
  55.                                     <div class="jp-volume-bar-value">  
  56.                                     </div>  
  57.                                 </div>  
  58.                                 <div class="jp-time-holder">  
  59.                                     <div class="jp-current-time">  
  60.                                     </div>  
  61.                                     <div class="jp-duration">  
  62.                                     </div>  
  63.                                     <ul class="jp-toggles">  
  64.                                         <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>  
  65.                                         <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>  
  66.                                     </ul>  
  67.                                 </div>  下载
  68.                             </div>  
  69.                             <div class="jp-title">  
  70.                                 <ul>  
  71.                                     <li>手册网</li>  
  72.                                 </ul>  
  73.                             </div>  
  74.                             <div class="jp-no-solution">  
  75.                                 <span>Update Required</span> To play the media you will need to either update your  
  76.                                 browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.  
  77.                             </div>  
  78.                         </div>  
  79.                     </div>  
  80.                     <div class="content">  
  81.                         <ul id="lrc_list">  
  82.                             <li>点击上方播放按钮……</li>  
  83.                         </ul>  
  84.                     </div>  
  85.                 </div>  
  86.             </div>  
  87.         </div>  
  88.         <script type="text/javascript" src="//apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script>   
  89.         <script type="text/javascript" src="/api/jq/5733e33322180/js/jquery.jplayer.js"></script>  
  90.         <script type="text/javascript" src="/api/jq/5733e33322180/js/lrc.js"></script>  
  91.         <script type="text/javascript">  
  92.             $(function() {  
  93.                 $("#jquery_jplayer_1").jPlayer({  
  94.                     ready: function(event) {  
  95.                         $(this).jPlayer("setMedia", {  
  96.                             mp3: "yangcong.mp3" //mp3的播放地址  
  97.                         });  
  98.                     },  
  99.                     timeupdate: function(event) {  
  100.                         if (event.jPlayer.status.currentTime == 0) {  
  101.                             time = "";  
  102.                         } else {  
  103.                             time = event.jPlayer.status.currentTime;  
  104.                         }  
  105.                     },  
  106.                     play: function(event) {  
  107.                         //点击开始方法调用lrc。start歌词方法 返回时间time  
  108.                         $.lrc.start($('#lrc_content').val(), function() {  
  109.                             return time;  
  110.                         });  
  111.                     },  
  112.                     ended: function(event) {  
  113.                         $("#lrc_list").removeAttr("style").html("<li>歌曲播放完毕!</li>");  
  114.                     },  
  115.                     swfPath: "js"//存放jplayer.swf的决定路径  
  116.                     solution: "html, flash"//支持的页面  
  117.                     supplied: "mp3"//支持的音频的格式  
  118.                     wmode: "window"  
  119.                 });  
  120.             });  
  121.         </script>