search
HomeWeb Front-endH5 TutorialSample code sharing of HTML5 practice lyrics synchronization player

We will find that the compatibility of song playback is not very good. For example, the flash player that can be played on IE is not a good application on Firefox or Chrome because of the obstruction of plug-ins!HTML5# The emergence of ## makes all this possible, but although the player plays, we still need to pay attention to the user experience, 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!

001	<!doctype html>
002	<html>
003	<head>
004	<meta charset=utf-8>
005	<title>歌词同步播放器-powered by widuu xiaowei</title>
006	<meta http-equiv="Cache-Control" content="no-cache">
007	<meta name="viewport" content="width=device-width; initial-scale=1.0; minimum-scale=1.0; maximum-scale=1.4">
008	<meta name="MobileOptimized" content="240">
009	<link href="/mp3/css/blue.css" rel="stylesheet" type="text/css" />
010	<script type="text/javascript" src="/mp3/js/jquery.js"></script>
011	<script type="text/javascript" src="/mp3/js/jquery.jplayer.js"></script>
012	<script type="text/javascript" src="/mp3/js/lrc.js"></script>
013	<style type="text/css">
014	* { margin:0; padding:0; }
015	ul, ol, dl { list-style:none; }
016	.content li.hover{ color:red; }
017	.content{ width:402px; height:200px; background:#ccc; overflow:hidden; padding:10px;}
018	</style>
019	<script>
020	//<![CDATA[
021	$(document).ready(function(){
022	    $("#jquery_jplayer_1").jPlayer({
023	        ready: function (event) {
024	            $(this).jPlayer("setMedia", {
025	                mp3:"yangcong.mp3" //mp3的播放地址
026	            }).jPlayer("play");
027	        },
028	        timeupdate: function(event) {
029	                if(event.jPlayer.status.currentTime==0){
030	                    time = "";
031	                }else {
032	                    time = event.jPlayer.status.currentTime;
033	                }
034	                 
035	            },
036	            play: function(event) {
037	                //点击开始方法调用lrc。start歌词方法 返回时间time
038	                 
039	                if(event.jPlayer.status.currentTime==0){
040	                    $("#jquery_jplayer_1").jPlayer("pause",1);
041	                }
042	                 
043	                if($(&#39;#lrc_content&#39;).val()!==""){
044	                $.lrc.start($(&#39;#lrc_content&#39;).val(), function() {
045	                    return time;
046	                });
047	                }else{
048	                    $(".content").html("没有字幕");
049	                }
050	            },
051	            repeat: function(event) {
052	              if(event.jPlayer.options.loop) {
053	                $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {
054	                  $(this).jPlayer("play");
055	                });
056	              } else {
057	                $(this).unbind(".jPlayerRepeat");
058	              }
059	            },
060	        swfPath: "/js",         //存放jplayer.swf的决定路径
061	        solution:"html, flash", //支持的页面
062	        supplied: "mp3",        //支持的音频的格式
063	        wmode: "window"      
064	         
065	    });
066	    $("#lrc_content").hide();
067	});
068	//]]>
069	</script>
070	</head>
071	<body>
072	<textarea id="lrc_content" name="textfield" cols="70" rows="10">
073	[ar:测试用 ]
074	[00:03.00]洋葱
075	[00:06.00]演唱:平安
076	[00:09.00]
077	[00:11.38]如果你眼神能够为我片刻的降临
078	[00:21.23]如果你能听到心碎的声音
079	[00:28.88]盘底的洋葱像我永远是配角戏
080	[00:35.74]偷偷的看着你偷偷的隐藏着自己
081	[00:43.48]
082	[00:44.90]如果你愿意一层一层
083	[00:48.46]一层的剥开我的心
084	[00:52.66]你会发现你会讶异
085	[00:56.40]你是我最压抑最深处的秘密
086	[01:00.26]如果你愿意一层一层
087	[01:03.69]一层的剥开我的心
088	[01:07.76]你会鼻酸你会流泪
089	[01:11.60]只要你能听到我看到我的全心全意
090	[01:18.30]
091	[01:19.11]如果你愿意一层一层
092	[01:22.57]一层的剥开我的心
093	[01:26.66]你会发现你会讶异
094	[01:30.41]你是我最压抑最深处的秘密
095	[01:34.48]如果你愿意一层一层
096	[01:37.58]一层的剥开我的心
097	[01:41.51]你会鼻酸你会流泪
098	[01:45.15]只要你能听到我看到我的全心全意
099	[01:53.55]
100	[01:55.65]你会鼻酸你会流泪
101	[01:59.84]只要你能听到我看到我的全心全意
102	[02:12.57]
103	</textarea>
104	 
105	 
106	<p>
107	 
108	        <div id="jquery_jplayer_1" class="jp-jplayer"></div>
109	 
110	        <div id="jp_container_1" class="jp-audio">
111	            <div class="jp-type-single">
112	                <div class="jp-gui jp-interface">
113	                    <ul class="jp-controls">
114	                        <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
115	                        <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
116	                        <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
117	                        <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
118	                        <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
119	                        <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
120	                    </ul>
121	                    <div class="jp-progress">
122	                        <div class="jp-seek-bar">
123	                            <div class="jp-play-bar"></div>
124	                        </div>
125	                    </div>
126	                    <div class="jp-volume-bar">
127	                        <div class="jp-volume-bar-value"></div>
128	                    </div>
129	                    <div class="jp-time-holder">
130	                        <div class="jp-current-time"></div>
131	                        <div class="jp-duration"></div>
132	 
133	                        <ul class="jp-toggles">
134	                            <li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
135	                            <li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
136	                        </ul>
137	                    </div>
138	                </div>
139	                <div class="jp-title">
140	                    <ul>
141	                        <li>mp3player powered by xiaowei</li>
142	                    </ul>
143	                </div>
144	                <div class="jp-no-solution">
145	                    <span>Update Required</span>
146	                    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>.
147	                </div>
148	            </div>
149	        </div>
150	                <div class="content"><ul id="lrc_list">
151	        点击开始播放……
152	        </ul></div><br />
153	</body>
154	 
155	</html>

The above is the detailed content of Sample code sharing of HTML5 practice lyrics synchronization player. 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
Deconstructing H5 Code: Tags, Elements, and AttributesDeconstructing H5 Code: Tags, Elements, and AttributesApr 18, 2025 am 12:06 AM

HTML5 code consists of tags, elements and attributes: 1. The tag defines the content type and is surrounded by angle brackets, such as. 2. Elements are composed of start tags, contents and end tags, such as contents. 3. Attributes define key-value pairs in the start tag, enhance functions, such as. These are the basic units for building web structure.

Understanding H5 Code: The Fundamentals of HTML5Understanding H5 Code: The Fundamentals of HTML5Apr 17, 2025 am 12:08 AM

HTML5 is a key technology for building modern web pages, providing many new elements and features. 1. HTML5 introduces semantic elements such as, , etc., which enhances web page structure and SEO. 2. Support multimedia elements and embed media without plug-ins. 3. Forms enhance new input types and verification properties, simplifying the verification process. 4. Offer offline and local storage functions to improve web page performance and user experience.

H5 Code: Best Practices for Web DevelopersH5 Code: Best Practices for Web DevelopersApr 16, 2025 am 12:14 AM

Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

H5: The Evolution of Web Standards and TechnologiesH5: The Evolution of Web Standards and TechnologiesApr 15, 2025 am 12:12 AM

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

Is H5 a Shorthand for HTML5? Exploring the DetailsIs H5 a Shorthand for HTML5? Exploring the DetailsApr 14, 2025 am 12:05 AM

H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

H5 and HTML5: Commonly Used Terms in Web DevelopmentH5 and HTML5: Commonly Used Terms in Web DevelopmentApr 13, 2025 am 12:01 AM

H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

What Does H5 Refer To? Exploring the ContextWhat Does H5 Refer To? Exploring the ContextApr 12, 2025 am 12:03 AM

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

H5: Tools, Frameworks, and Best PracticesH5: Tools, Frameworks, and Best PracticesApr 11, 2025 am 12:11 AM

The tools and frameworks that need to be mastered in H5 development include Vue.js, React and Webpack. 1.Vue.js is suitable for building user interfaces and supports component development. 2.React optimizes page rendering through virtual DOM, suitable for complex applications. 3.Webpack is used for module packaging and optimize resource loading.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version