]."> How to create scrolling lyrics in html-HTML Tutorial-php.cn

How to create scrolling lyrics in html

coldplay.xixi
Release: 2023-01-03 09:27:42
Original
8966 people have browsed it

htmlHow to make scrolling lyrics: First write the encoding format in the tag, introduce css style and jQuery; then place the player, the code is [

How to create scrolling lyrics in html

The operating environment of this tutorial: windows7 system, html5 version, DELL G3 computer.

html How to make scrolling lyrics:

First we create an html file, with a random name, such as: index.html, this is simple, needless to say. Don’t rush to start writing code, we are creating a css For the file, you might as well name it musicplay.css. For js, we can directly write it into the html file for easy reading and adjustment. We will not create a new js file, but you need to prepare a jQuery file. If you don’t have it, it doesn’t matter. I will talk about the solution later. . The preparation work is over, and we start writing. First, write the encoding format in the tag, and by the way, introduce the css style and jQuery we created before. The code is as follows:

The code is as follows:

爱在西元前-周杰伦    
Copy after login

After the head content is written, we start to write the body. First we use the placement player, which is the label. The code is as follows:

Copy after login

Just go there-->Then write a Box, the code is as follows:

The css code of the box is as follows (see the remarks for the function):

The next step is the js script. Our design idea is (completed by the following functions):

Function 1: parseLyric() splits the lyrics. This step is mainly to display the lyrics in separate lines.

Function 2: highLight() highlights the lyrics currently placed in order to indicate where the current song is. One sentence

Function 3: audio.addEventListener() renders in real time, because it is scrolling, so it must be rendered continuously

Function 4: getLineNo() gets the number of lines at this time, if When we fast forward or rewind, the lyrics will also change according to our adjustments

Function 5: audio.addEventListener() returns to the beginning after playing. You don’t need to do this. It doesn’t make much sense. This is for After perfecting the functions and explaining these functions, I will post the code directly.

Copy after login

Related learning recommendations:html video tutorial

The above is the detailed content of How to create scrolling lyrics in html. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!