HTML5 Audio label Homemade music player

Source: Internet
Author: User
Tags shuffle

Related skills
    • HTML5+CSS3(Implement page layout and dynamic effects)
    • Iconfont(Use vector icon Gallery to add player related icons)
    • LESS(Dynamic CSS Authoring)
    • jQuery(quickly write JS script)
    • gulp+webpack(Automated build tools for compiling and compressing code such as LESS,CSS,JS)
Features implemented
    • Play Pause (click to toggle Playback status)
    • Next Song (toggle next)
    • Shuffle (play the next song automatically after the current songs are played)
    • Single loop (click the shuffle icon to switch to the single loop)
    • Volume adjustment (mouse over slide to set volume size)
    • Song Progress bar (click to toggle the progress of the jump, you can also click the small dots to drag and drop the progress)
    • Real-time lyrics (click words, toggle lyrics interface, automatically scroll lyrics based on real-time progress)
    • Like (click Add an active effect)
    • Share (can be directly shared to Sina Weibo)
Audio Label Use
    • autoplayAuto Play
    • loopLoop playback
    • volumeVolume settings
    • currentTimeCurrent playback position
    • durationLength of audio
    • pauseTime out
    • playPlay
    • endedReturns whether the audio has ended
Play and Pause code
function(){    var _this = this; this.play.on(‘click‘, function(){ if (_this.audio.paused) { _this.audio.play(); $(this).html(‘‘); } else { _this.audio.pause(); $(this).html(‘‘) } });}
Music progress bar code
_music.prototype.volumedrag =function){var _this =ThisThis.btn.on (' MouseDown ',function) {_this.clicking =True _this.audio.pause (); })This.btn.on (' MouseUp ',functionfalse; _this.audio.play ();}) this.progress.on ( ' MouseMove click ', function (e) {if (_this.clicking | | E.type = = =  ' click ') {var len = $ ( This). Width (), left = E.pagex-$ (this). Offset (). Left, volume = Left/len; if (volume <= 1 | | volume >= 0) {_ this.audio.currentTime = volume * _this.audio.duration; _this.progressline.css ( ' width ', volume *100 + 
Lyrics Add code
_music.prototype.readylyric =function(lyric) {This.lyricBox.empty ();var lyriclength =0;var html =  ' <div class= ' Lyric-ani ' data-height= ' > '; Lyric.foreach (function ( Element,index) {var ele = Element[1] = = = undefined?  ' ^_^ Lyrics error ^_^ ': Element[1]; HTML + =  <p class= "Lyric-line" data-id= "' +index+" "data-time=" ' + element[ 0] +  ">" + ele +  </p> "; lyriclength++; }); HTML + =  ' </div> '; this.lyricbox.append (HTML); this.ontimeupdate (lyriclength);}         

There is a lot of code to add, I feel that the line can click like (also in my GitHub to a star), your favorite and star is my continued creation of power, thank you!!! SOURCE Add Group

You are welcome to join the Learning Exchange Group if you encounter any problems or want to acquire learning resources in the learning process.
343599877, we learn the front-end together!

HTML5 Audio label Homemade music player

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.