myhtml Player Release v1.1

Source: Internet
Author: User
Tags add array object return split window

Copy the following code to the local, save as HTA file using

Features: Automatic access to Baidu song top500 and link

Using AJAX technology, automatic paging

Note: The ADODB.stream object is used in the code and may be judged by antivirus software as malicious.

Run Code Box

<ptml><pead><title>my HTML player-by hutia</title><pta:application id= "App1" Singleinstance= "yes" contextmenu= "yes" sysmenu= "yes" windowstate= "normal" maximizebutton= "no" minimizebutton= "yes" Applicationname= "Myhtmlplayer" version= "1.1" innerborder= "no" caption= "yes" showintaskbar= "yes" border= "thin"/> <meta http-equiv= "Content-type" content= "text/html; charset= "gb2312" ><style>body {overflow:auto;font-size:12px;cursor:default;padding:3px;margin:0px; border-width:0px;} #f1 {display:none;} #table01 {font-size:12px;background-color:black;color:white;text-align:center;float:left;height:300px;} #table01 Td{vertical-align:top;} #MediaPlayer1 {width:300px;height:300px;} #playListTitle {background-color: #001122; color:white;font-size:12px;font-weight:bold;width:100%;height:16px; padding:2px;} #playList {width:150px;height:280;margin:0px;font-size:12px;background-color:black;color:white;} #musicList {width:260px;border:buttonface 4px groove;height:200px;float:right;} #musicListTitle {font-size:13px;width:100%;height:20px;background-color: #C5FFC5;p adding:3px;font-weight:bold;} #musicListContent {height:200px;} #musicList. Item {Width:100%;height:20px;line-height:12px;padding:0px;margin:0px;overflow-y:hidden;} #musicList. Item A {color: #773; text-decoration:none;width:180px;height:20px;line-height:12px;padding-top:5px; Padding-left:10px;margin:0px;position:relative;overflow:hidden;text-overflow:ellipsis;} #musicListNav {height:18px;} #processBar {position:absolute;width:99%;height:30px;border:buttonface 2px inset;z-index:99;background-color: #FFF ; bottom:5px;left:5px;padding:5px;}. add2listbtn {width:18px;line-height:14px;text-align:center;cursor:hand;font-size:14px;font-family:webdings}. add2listbtn2 {width:18px;line-height:14px;text-align:center;cursor:hand;font-size:14px;} </style><script>//**** global variable definition area ************taskstate= "loadlist"; url= "Http://list.mp3.baidu.com/topso /mp3topsong.html "; taskurls=new array (); tasknames=new Array ();p agesize=10;p ageno=0;currenttask=pageno*pagesize;maxtask=currenttask+pagesize;windowwidth=740;windowheight=400;//**** Initialize the component ***************try{var xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");} catch (E) {document.write ("<p> failed to load, component blocked </p>"); Try{top.moveto ((screen.availwidth-windowwidth)/2, (Screen.availheight-windowheight)/2); Top.resizeto (windowWidth , windowheight);} catch (E) {}//**** procedure function area ***************//---initialization-------function init () {mediaplayer1.autorewind=false; Mediaplayer1.autostart=true; Mediaplayer1.sendplaystatechangeevents=true; Mediaplayer1.attachevent ("Playstatechange", Checkplaystatus); Initloadmusic ();} ### #关于baidu音乐获取的代码 ######//---Initialize the download-----function initloadmusic () {currenttask=pageno*pagesize-1;maxtask= Currenttask+pagesize;musiclistcontent.innerhtml= "";p rocessbar.style.display= ""; Loadbaidumusic ();} ---Start downloading music from Baidu-----function Loadbaidumusic () {//If the status is Loadmusic then remove the address from the URL list if (taskstate== "Loadmusic") { Currenttask++;if (currenttask>maxtask| | CURRENTTASK&GT;TASKURLS.LENGTH-1) {//download completeTry{cleartimeout (Vbtimer);} catch (E) {}processbar.style.display= "none"; Createnavigate (); return (false); if (currenttask>taskurls.length-1) {currenttask--;settimeout (loadbaidumusic,1000); return (false); Url=taskurls[currenttask];} Xmlhttp.open ("Get", url,true); Xmlhttp.send (); Xmlhttp.onreadystatechange=checkxmlhttpstate;checkxmlhttpstate ();} ----Process Download-----function checkxmlhttpstate () {if (xmlhttp.readystate==4) {if (xmlhttp.status==200) {if (taskstate==) Loadlist ") {taskstate=" loadmusic ";//Analysis download content generate song address list analybaidulist (); currenttask=-1;} else{//obtains mp3 's real address analybaidumusic ();} Loadbaidumusic ();} ----Analysis downloads Generate song address lists----function analybaidulist () {var strhtml=b2s (xmlhttp.responsebody); var istart=strhtml.search (/<body/i); var iend=strhtml.tolowercase (). IndexOf ("<\/script", istart+5); Strhtml=strhtml.substring (IStart, Iend); var fff=document.createelement ("Iframe"); fff.id= "Tempframe"; fff.style.display= "None"; Document.body.insertBefore (FFF); Thewin=eval ("Tempframe"); TheWin.document.open (); TheWin.document.cleaR (); TheWin.document.write (strhtml); TheWin.document.close (); for (Var i=0;i<thewin.document.links.length;i++) { if (Thewin.document.links[i].href.match (/mp3.baidu.com\/m\?tn=baidump3\&ct=/i) && Thewin.document.links[i].parentnode.firstchild==thewin.document.links[i]) {//deposit URL in Taskurls, The song name is deposited in Tasknamestaskurls[taskurls.length]=thewin.document.links[i].href.replace (/lm=-1/, "lm=0"); taskNames[ Tasknames.length]=thewin.document.links[i].innertext}} Fff.outerhtml= "";} ----Get MP3 's real address, add to music list-----function analybaidumusic () {var strhtml=b2s (xmlhttp.responsebody); var strtxt= tasknames[currenttask];//the regular var aryurl=strhtml.match (/http:\/\/[^]+/gi) that matches the URL; if (!aryurl) {return (false);} var thec=document.createelement ("DIV"); thec.classname= "Item"; Musiclistcontent.insertbefore (THEC); Get 10 addresses to avoid link invalidation for (var i=0;i<10&&i<aryurl.length;i++) {//container var thed=document.createelement for each item (" DIV "); Thed.onmouseover=musiclist_mouseover;thed.onmouseout=musiclist_mouseout;//link element var TheLink=docUment.createelement ("A"); var strurl=aryurl[i].substring (2,aryurl[i].length-2); thelink.href=strurl;thelink.title =strurl;thelink.innertext= (currenttask+1) + "." +strtxt;if (i>0) {thelink.innertext+= "." + (i+1);} Thelink.onclick=musiclist_item_click;thed.insertbefore (Thelink);//Add to List button Thebutton=document.createelement (" Span "); Thebutton.classname=" add2listbtn "; thebutton.innertext=" 1 "; thebutton.title=" add to List "; thebutton.onclick= Musiclist_add2listbtn_click;thebutton.onmouseover=musiclist_item_mouseover;thebutton.onmouseout=musiclist_item _mouseout;thed.insertbefore (Thebutton)/Roll up button thebutton=document.createelement ("Span"); Thebutton.classname= " Add2listbtn "; thebutton.innertext=" 3 "; thebutton.title=" roll up "; Thebutton.onclick=musiclist_scrollupbtn_click; Thebutton.onmouseover=musiclist_item_mouseover;thebutton.onmouseout=musiclist_item_mouseout;thed.insertbefore ( Thebutton)//Next Roll button thebutton=document.createelement ("Span"); Thebutton.classname= "ADD2LISTBTN"; thebutton.innertext= "4"; thebutton.title= "Next volume"; thebutton.onclick=musiclist_scrolldownbtn_click;thebutton.onmouseover=musiclist_item_mouseover;thebutton.onmouseout= Musiclist_item_mouseout;thed.insertbefore (Thebutton);//Open new Window button thebutton=document.createelement ("Span"); Thebutton.classname= "add2listbtn"; thebutton.innertext= "2"; thebutton.title= "open a new window"; thebutton.onclick=musiclist_ Newwinbtn_click;thebutton.onmouseover=musiclist_item_mouseover;thebutton.onmouseout=musiclist_item_mouseout; Thed.insertbefore (Thebutton); Thec.insertbefore (thed);} ### #关于播放器播放音乐的代码 ######//----Check the Player status-------function Checkplaystatus (oldstate,newstate) {try{if ( mediaplayer1.playstate==0) {mediaplayer1.detachevent ("Playstatechange", checkplaystatus); Mediaplayer1.stop (); if (playlist.options.selectedindex<playlist.options.length-1) {playList.options[ Playlist.options.selectedindex+1].selected=true;} Else{playlist.options[0].selected=true;} Mediaplayer1.filename=playlist.value; Mediaplayer1.play (); settimeout (' Mediaplayer1.attachevent ("Playstatechange", checkplaystatus); ', 5000);}} catch (e) {}}//**********event function area***************//----------play List Event Start-------------Function playlist_ DragOver () {event.returnvalue=false;} function Playlist_dragenter () {event.returnvalue=false;event.datatransfer.dropeffect= ' link ';} function Playlist_drop () {Strtxt=unescape (Event.dataTransfer.getData (' Text '). Split (":") [0]). Replace (/\[\+\]/, "") ;; Strurl=unescape (Event.dataTransfer.getData (' Text '). Split (":") [1]). Replace (/\[\+\]/, "");; Playlist.options[playlist.options.length]=new Option (Strtxt,strurl);} function Playlist_keydown () {if (event.keycode==46) {Try{playlist.options[playlist.options.selectedindex]. Outerhtml= "";} catch (E) {}return (false);} if (event.keycode==13) {Playlist_dblclick (); return (false);}} function Playlist_dblclick () {mediaplayer1.detachevent ("Playstatechange", checkplaystatus); Mediaplayer1.filename=playlist.value; Mediaplayer1.play (); settimeout (' Mediaplayer1.attachevent ("Playstatechange", checkplaystatus); ', 1000;} ----------Music List Event Start-------------function MusiclisT_dragstart () {if (event.srcelement.tagname== ' A ') {event.dataTransfer.setData (' Text '), Escape ( Event.srcElement.innerText) + ":" +escape (Event.srcElement.href));} Else{return (false);} function Musiclist_mouseover () {this.style.backgroundcolor= "#D5EFD5";} function Musiclist_mouseout () {this.style.backgroundcolor= "";} function Musiclist_item_mouseover () {this.style.color= "gold";} function Musiclist_item_mouseout () {this.style.color= "";} function Musiclist_item_click () {strtxt=event.srcelement.innertext;strurl=event.srcelement.href; Playlist.innerhtml= "";p laylist.options[0]=new Option (strtxt,strurl);p laylist.options[0].selected=true; Event.returnvalue=false;playlist_dblclick (); return (false);} function Musiclist_add2listbtn_click () {Strtxt=event.srcelement.parentnode.firstchild.innertext.replace (/\[\+\]/ , ""); Strurl=event.srcelement.parentnode.firstchild.href;playlist.options[playlist.options.length]=new Option ( Strtxt,strurl); return (false);} function Musiclist_scrollupbtn_click () {This.parentNode.parentNode.scrollTop-=20;} function Musiclist_scrolldownbtn_click () {this.parentnode.parentnode.scrolltop+=20;} function Musiclist_newwinbtn_click () {open (this.parentNode.firstChild.href);} function Musiclist_nav_click () {pageno=this.pageid;musiclistnav.disabled=true;this.style.color= "#FF0000"; for (var I=0;i<musiclistnav.all.tags ("span"); i++) {musicListNav.all.tags ("span") [I].onclick=null;} Initloadmusic ();} Private functions lib***************function B2s (b) {var adodbstream=new activexobject ("ADODB. Stream "); Adodbstream.type=1;//1=adtypebinary Adodbstream.open (); Adodbstream.write (b); adodbstream.position=0; adodbstream.type=2; Adodbstream.charset= "gb2312"; Adodbstream.charset= "_autodetect_all"; var re=adodbstream.readtext (); Adodbstream=null; return (re); function Createnavigate () {musiclistnav.innerhtml= ""; Musiclistnav.disabled=false;var Themax=taskurls.length;var Thec=document.createelement ("span"); Musiclistnav.insertbefore (THEC);themin=pageno-4>0?pageno-4:0; Thepagecount=parseint (Themax/pagesize) + (themax%pagesize==0?0:1); themax=pageno+5<thepagecount?pageno+5:thepagecount;thebutton= Document.createelement ("span"); Thebutton.classname= "add2listbtn"; thebutton.innertext= "7"; thebutton.pageid=0; thebutton.onmouseover=musiclist_item_mouseover;thebutton.onmouseout=musiclist_item_mouseout;thebutton.onclick= Musiclist_nav_click;thec.insertbefore (Thebutton); for (Var j=themin;j<themax;j++) {thebutton= Document.createelement ("span"); Thebutton.classname= "add2listbtn2"; thebutton.innertext=j+1;thebutton.pageid=j; if (J!=pageno) {thebutton.onmouseover=musiclist_item_mouseover;thebutton.onmouseout=musiclist_item_mouseout; Thebutton.onclick=musiclist_nav_click;} Else{thebutton.style.color= "Blue";} Thec.insertbefore (Thebutton);} Thebutton=document.createelement ("span"); Thebutton.classname= "add2listbtn"; thebutton.innertext= "8"; Thebutton.pageid=thepagecount-1;thebutton.onmouseover=musiclist_item_mouseover;thebutton.onmouseout=musiclist_ Item_mouseout;thebutton.onclick=musiclist_nav_click;theC.insertbefore (Thebutton);} </script><body ><!--song list--><div id=musiclist ondragstart= "Musiclist_dragstart ();" ><div id=musiclisttitle>all music</div><div id=musiclistcontent></div><pr> Paging: <br><div id=musiclistnav></div><pr><marquee scrolldelay=50 scrollamount=1>Tips: Drag the song into the playlist     tips: Click the left and right arrows to change the music address </marquee></div><!--status bar--><div id= Processbar style= "Display:none;" >Processing...</div><!--player--><table id=table01><tr><td><object classid= " Clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95 "id=" MediaPlayer1 "standby=" Loading Windows Media Player components ... " Type= "Application/x-oleobject" ><param name= "Audiostream" value= "-1" ><param name= "AutoSize" value= "-1" ><!--Whether the playback size is automatically resized--><param name= "AutoStart" value= "0" ><!--automatically play--><param name= " Animationatstart "value="-1 "><param name=" Allowscan "V"Alue= "-1" ><param name= "Allowchangedisplaysize" value= "-1" ><param name= "autorewind" value= "0" >< param name= "Balance" value= "0" ><!--left-right channel balance, the leftmost-9640, the most right-hand 9640--><param name= "BaseURL" Value><param Name= "Bufferingtime" value= "><!--buffer time--><param name=" Captioningid "Value><param name=" Clicktoplay "value="-1 "><param name=" CursorType "value=" 0 "><param name=" currentposition "value=" 0 "> <!--current playback Progress-1 means unchanged, 0 indicates the beginning unit is a second, for example, 10 indicates that the value must be-1.0 or greater than or equal to 0--><param name= "Currentmarker" value= "0" > <param name= "Defaultframe" Value><param name= "Displaybackcolor" value= "0" ><param name= " Displayforecolor "value=" 16777215 "><param name=" DisplayMode "value=" 0 "><param name=" DisplaySize "value= "0" ><!--video 1-50%, 0-100%, 2-200%,3-full screen other values for 0 processing, decimal is rounded then followed by the processing--><param name= "Enabled" value= "-1" > <param name= "Enablecontextmenu" value= "-1" ><!-whether to use the right-click pop-up menu to control--><param name= "Enablepositioncontrols" Value= "-1" ><param name= "Enablefullscreencontrols" value= "-1" ><param name= "Enabletracker" value= "-1" ><!--whether to allow pulling the playback progress bar to any place play--><param name= "Filename" value= "valuetype=" ref "><param name=" Invokeurls "value="-1 "><param name=" Language "value="-1 "><param name=" Mute "value=" 0 "><!--Mute ><param name= "Playcount" value= "ten" ><!--repeat playback times, 0 for always repeat--><param name= "PreviewMode" value= "-1" > <param name= "Rate" value= "1" ><!--Playback Speed 1.0-twice times the speed play--><param name= "Samilang" Value><param name= "Samistyle" Value><param name= "Samifilename" value><!--choose to play simultaneously (sound) songs--><param name= " SelectionStart "value="-1 "><param name=" Selectionend "value="-1 "><param name=" Sendopenstatechangeevents "value="-1 "><param name=" sendwarningevents "value="-1 "><param name=" Senderrorevents "value="-1 "><param name=" sendkeyboardevents "value=" 0 "><param name=" Sendmouseclickevents "value=" 0 "><param NAme= "sendmousemoveevents" value= "0" ><param name= "sendplaystatechangeevents" value= "-1" ><param name= " Showcaptioning "value=" 0 ><!--display subtitles, for a black, there will be a large block of black, generally do not show--><param name= "Showcontrols" value= "-1" ><!--whether to display control, such as playback, stop, pause--><param name= "Showaudiocontrols" value= "-1" ><!--whether to display volume control-->< param name= "showdisplay" value= "0" ><!--display program information, such as copyright--><param name= "Showgotobar" value= "0" ><!-- A box, below, there are down arrow--><param name= "Showpositioncontrols" value= "1" ><!--whether to show forward and list, if the display is generally also gray uncontrollable--> <param name= "ShowStatusBar" value= "-1" ><!--current playback information, showing whether it is playing, and the total playback time and the time currently played--><param Name= " Showtracker "value="-1 "><!--whether the current playback track bar is displayed, that is, the current playback progress bar--><param name=" Transparentatstart "value="-1 "> <param name= "videoborderwidth" value= "0" ><!--the width of the display, if less than the width of the video, the minimum is video width, or to the specified value, and automatically increase the height. This change only changes the black box size of four weeks, Do not change the video size--><param name= "Videobordercolor" value= "0" ><!--display the color of the black box, RGB values, such as ffff00 for yellow--><param name = "VideoboRder3d "value=" 0 "><param name=" Volume "value=" 0 "><!--volume, a negative value is the current volume of the reduction, values automatically take absolute, the maximum is 0, the smallest is-9640, the largest 0-- ><param name= "Windowlessvideo" value= "0" ><!--if 0 allows full screen, you can view--></object></td> only in Windows <td><div id=playlisttitle>play list:</div><select id=playlist size=2 ondragover= "PlayList_ DragOver (); "Ondragenter=" Playlist_dragenter (); "ondrop=" Playlist_drop (); " Ondblclick= "Playlist_dblclick ();" ></select></td></tr></table><body></ptml>

[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]



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.