jquery Music Player (lyrics scrolling version)

Source: Internet
Author: User

Long time no water out!!! Busy looking for Work ~ Then the mid-Autumn festival also counted, I wish you coding, directly awakened the seventh sense of the small universe, direct intentions can find bug-_-//finally title This is a very regular coding article

Probably than the previous added a lyrics, before the bombing, and then recently repaired, has been moving things, this estimate does not move, the big deal orange in the buy a few space HoHo

The effect is about a bit, spent 1 quick write out of ~ all said every program ape have aDesign LionOfHeart , but I remember I used to start code before the design of the time, there is a sentence you do not come out of the design will not copy Ah , and then I will be shameless pirates of the map. 23333

head A lot of people say ugly, train and sky, then there is a little meaning of it! Can listen to the "love transfer" There is a word lyrics

$.ajax ({URL:"/music/music.txt", type:"Get", Success:function(data) {data=Jquery.parsejson (data); varLength =data.length; varNow=0;  for(i = 0; i < length; i++) {            $("#musicText li"). EQ (i). After ("<li>" + Data[i].text + "</li>")        }        varPlayer ={playbutton: $ (". Play"), Songtext: $ (". Musictext"), state:0,            //0 plays, 1 pausesAudio: $ ("#audio"). Get (0), bind:function() {                //bind button                //Play or PauseConsole.log ($.type ( This)) Console.log ($.type ( This))                varobj = This;  This. Playbutton.click (function() {obj.changestate (obj.state? 0:1);                }); //Set Sound$ ("#voice"). Click (function(ex) {varPercent = (Ex.clientx-$ ( This). Offset (). left)/$ ( This). width ();                Obj.setvoice (percent);                }); //Default Sound 0.8Obj.setvoice (1.0); //Mute$ ("#voiceOP"). Click (function() {                    if(obj.muted) {$ ( This). Removeclass ("muted"); Obj.audio.muted=false; Obj.muted=false; } Else {                        $( This). addclass ("muted"); Obj.audio.muted=true; Obj.muted=true;                        }                }); //Set Progress$ ("#MusicProgress"). Click (function(ex) {varPercent = (Ex.clientx-$ ( This). Offset (). left)/$ ( This). width (); Obj.setprogress (Percent,false);                        }); //Last Song$ ("#prev"). Click (function() {Obj.nowindex--; if(Obj.nowindex < 0) Obj.nowindex = obj.list.length-1;                        Obj.playsing (Obj.nowindex);                        }); //Next Song$ ("#next"). Click (function() {Obj.nowindex++; if(Obj.nowindex >= obj.list.length) obj.nowindex = 0;                    Obj.playsing (Obj.nowindex);                Player.audio.play ();                        }); //Bind event-Play time Change                 This. audio.ontimeupdate =function() {obj.timechange (); }                //Play End                 This. audio.onended =function() {obj.singend (); }                    },            //Toggle Playback StatusChangestate:function(_state) { This. State =_state; if(! This. State) {                     This. Playbutton.removeclass ("pause"). AddClass ("Play");  This. Pause (); } Else {                     This. Playbutton.removeclass ("Play"). AddClass ("Pause");  This. Play (); }            },            //PlayPlayfunction() {                 This. Audio.play (); },            //PausePausefunction() {                 This. Audio.pause (); }, Timechange:function() {                varNowsec = Math.floor ( This. Audio.currenttime); Console.log (nowsec) console.log (data[now].time)if(nowsec>data[now].time) { Now= Now + 1; Console.log (now) $ ("#musicText li"). EQ (now). addclass ("active"). Siblings ("Li"). Removeclass ("active").); $("#musicText"). CSS ("Top",-(24*now) +138)                                    }                varTotalsec = Math.floor ( This. audio.duration); //Current Progress Display                varSectip = Secformat (nowsec) + "/" +Secformat (TOTALSEC); if(Sectip.length = =) $ ("#secTip"). HTML (SECTIP);  This. setprogress (Nowsec/totalsec,true); }, Setvoice:function(percent) {$ ("#voice"). Children (". Bar"). CSS ("width", percent * 100 + "%"); $("#voice"). Children ("a"). CSS ("left", percent * 100 + "%"));  This. Audio.volume =percent; }, Setprogress:function(Percent, JUSTCSS) {$ ("#MusicProgress"). Children (". Bar"). CSS ("width", percent * 100 + "%"); $("#MusicProgress"). Children ("a"). CSS ("left", percent * 100 + "%")); if(!JUSTCSS) This. Audio.currenttime = This. audio.duration *percent; }, Singend:function() {                if( This. style = = 0) {                     This. nowindex++; if( This. Nowindex >= This. list.length) This. Nowindex = 0;  This. playsing ( This. Nowindex); } Else {                    varindex = Math.floor (Math.random () * ( This. List.length + 1))-1; Index= Index < 0? 0: Index; Index= Index >= This. list.length? ( This. list.length-1): index;  This. playsing (index);  This. Nowindex =index;                }            },        };        Player.bind (); functionSecformat (num) {varm = Math.floor (num/60); vars = math.floor (num% 60); returnMakeformat (m) + ":" +Makeformat (s); functionMakeformat (n) {if(n >= 10)returnN; Else {                    return"0" +N; }            }        } }})

Then the code here is alpha0.0.1 version, has been upgrading ing

Continue to change the bug, the direct site source code can be viewed ~

Finally the big God see Don't face, don't attack me t_t, don't leave Hacker~email. I have restored n times this month ... I'm not really happy about this stuff, it's a safe dog.

jquery Music Player (lyrics scrolling version)

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.