Code for implementing the music player (html5 + css3 + jquery) and html5css3
Let's see how it works? The following small series will share with you some of my treasures. Lisa sang an episode at angel beats. This music player is implemented using html5, css, and jquery.
Lisa sang an episode at angel beats.
Finally, before explaining how to write this thing, I am a 24-year-old man from Shanghai. I am looking for a girlfriend and asked for a gentle personality... (Omitted 500 words)
<Div class = "Music"> <div class = "MusicPlaySound"> <div class =" MusicPlayBox ">
The html part is skipped .... It can basically be written...
.MusicPlayProcess.rotate{animation:rotate 30s infinite linear;}.MusicPlayProcess.pause{animation-play-state:paused;-webkit-animation-play-state:paused;}.MusicPicName.PicNameRotate{animation:rotate 4s infinite linear;}.MusicPicName.pause{animation-play-state:paused;-webkit-animation-play-state:paused;}@keyframes rotate{ from{ transform:rotate(0deg)} to{ transform:rotate(360deg)}}
Css is mainly interesting.
About a few css3 animations .... The one above
Copy codeThe Code is as follows:
. MusicPlayProcess. rotate
{Animation: rotate 30 s infinite linear ;}
You can change this 30 s to the length of the song to a progress bar ~ HOHOHOHO)
Infinite unlimited playback, you know.
Copy codeThe Code is as follows:
. MusicPicName. pause {animation-play-state: paused;
-Webkit-animation-play-state: paused ;}
Then pause the animation ,,,,
Compatibility is tough. Nothing else.
$(function(){ var play=1; $(".MusicPicButton").click(function(){ if(play==0){ $(this).attr("src","image/music/pause.png") $(".MusicPlayProcess").removeClass("pause") $(".MusicPicName").removeClass("pause") $("audio").get(0).play(); play=1; }else{ $(this).attr("src","image/music/play.png") $(".MusicPlayProcess").addClass("pause") $(".MusicPicName").addClass("pause") play=0; $("audio").get(0).pause(); } })})
Here is the Jq Section
Play? OK Current Status 1 play 0 pause
Copy codeThe Code is as follows:
$ ("Audio"). get (0). play ();
$ ("Audio"). get (0). pause ();
The above is all the content of this article. I hope you will like it.