Home  >  Article  >  Web Front-end  >  HTML5 implements parsing of players compatible with major browsers

HTML5 implements parsing of players compatible with major browsers

不言
不言Original
2018-06-11 17:45:492400browse

This article mainly introduces HTML5 to achieve perfect compatibility with the players of major browsers. Friends who need it can refer to the

song playback. We will find that its compatibility is not very good. For example, it can be played on IE. The flash player for playback is not a good application on Firefox or Chrome because of the obstruction of plug-ins! The emergence of HTML5 has made all this possible, but although the player can play, we still need to pay attention to the user experience. degree, so we wrote an HTML-compatible player! It is backward compatible with IE6-9, chrome, firfox, opera and other mainstream players. It should be fully compatible! The implementation principle code is presented to everyone!

<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>歌词同步播放器-powered by widuu xiaowei</title>
<meta http-equiv="Cache-Control" content="no-cache">
<meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.4">
<meta name="MobileOptimized" content="240">
<link href="/mp3/css/blue.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/mp3/js/jquery.js"></script>
<script type="text/javascript" src="/mp3/js/jquery.jplayer.js"></script>
<script type="text/javascript" src="/mp3/js/lrc.js"></script>
<style type="text/css">
* { margin:0; padding:0; }
ul, ol, dl { list-style:none; }
.content li.hover{ color:red; }
.content{ width:402px; height:200px; background:#ccc; overflow:hidden; padding:10px;}
</style>
<script>
//<![CDATA[
$(document).ready(function(){
 $("#jquery_jplayer_1").jPlayer({
  ready: function (event) {
   $(this).jPlayer("setMedia", {
    mp3:"yangcong.mp3" //mp3的播放地址
   }).jPlayer("play");
  },
  timeupdate: function(event) {
    if(event.jPlayer.status.currentTime==0){
     time = "";
    }else {
     time = event.jPlayer.status.currentTime;
    }
   },
   play: function(event) {
    //点击开始方法调用lrc。start歌词方法 返回时间time
    if(event.jPlayer.status.currentTime==0){
     $("#jquery_jplayer_1").jPlayer("pause",1);
    }
    if($(&#39;#lrc_content&#39;).val()!==""){
    $.lrc.start($(&#39;#lrc_content&#39;).val(), function() {
     return time;
    });
    }else{
     $(".content").html("没有字幕");
    }
   },
   repeat: function(event) {
     if(event.jPlayer.options.loop) {
    $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {
      $(this).jPlayer("play");
    });
     } else {
    $(this).unbind(".jPlayerRepeat");
     }
   },
  swfPath: "/js",    //存放jplayer.swf的决定路径
  solution:"html, flash", //支持的页面
  supplied: "mp3",  //支持的音频的格式
  wmode: "window"    
 });
 $("#lrc_content").hide();
});
//]]>
</script>
</head>
<body>
<textarea id="lrc_content" name="textfield" cols="70" rows="10">
[ar:测试用 ] 
[00:03.00]洋葱
[00:06.00]演唱:平安
[00:09.00]
[00:11.38]如果你眼神能够为我片刻的降临
[00:21.23]如果你能听到心碎的声音
[00:28.88]盘底的洋葱像我永远是配角戏
[00:35.74]偷偷的看着你偷偷的隐藏着自己
[00:43.48]
[00:44.90]如果你愿意一层一层
[00:48.46]一层的剥开我的心
[00:52.66]你会发现你会讶异
[00:56.40]你是我最压抑最深处的秘密
[01:00.26]如果你愿意一层一层
[01:03.69]一层的剥开我的心
[01:07.76]你会鼻酸你会流泪
[01:11.60]只要你能听到我看到我的全心全意
[01:18.30]
[01:19.11]如果你愿意一层一层
[01:22.57]一层的剥开我的心
[01:26.66]你会发现你会讶异
[01:30.41]你是我最压抑最深处的秘密
[01:34.48]如果你愿意一层一层
[01:37.58]一层的剥开我的心
[01:41.51]你会鼻酸你会流泪
[01:45.15]只要你能听到我看到我的全心全意
[01:53.55]
[01:55.65]你会鼻酸你会流泪
[01:59.84]只要你能听到我看到我的全心全意
[02:12.57]
</textarea></p>
<p><p>
  <p id="jquery_jplayer_1" class="jp-jplayer"></p>
  <p id="jp_container_1" class="jp-audio">
   <p class="jp-type-single">
    <p class="jp-gui jp-interface">
     <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>
     <p class="jp-progress">
      <p class="jp-seek-bar">
       <p class="jp-play-bar"></p>
      </p>
     </p>
     <p class="jp-volume-bar">
      <p class="jp-volume-bar-value"></p>
     </p>
     <p class="jp-time-holder">
      <p class="jp-current-time"></p>
      <p class="jp-duration"></p>
      <ul class="jp-toggles">
       <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>
     </p>
    </p>
    <p class="jp-title">
     <ul>
      <li>mp3player powered by xiaowei</li>
     </ul>
    </p>
    <p 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="<a href="http://get.adobe.com/flashplayer/">http://get.adobe.com/flashplayer/</a>" target="_blank">Flash plugin</a>.
    </p>
   </p>
  </p>
    <p class="content"><ul id="lrc_list">
  点击开始播放……
  </ul></p>
</body>
</html>

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Using HTML5 to implement web music player

Solution to the problem that the video tag in html5 cannot play mp4 Method

The above is the detailed content of HTML5 implements parsing of players compatible with major browsers. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn