播放器 //linfeng@gx165.com function classMedia(_mediaid,_showTextid,_objname) { //外部属性========================================================================= this.CYL=true;//连续播放标志 this.RDM=false;//无序播放(true为无序播放) this.MASMODE=true;//主模式,当用弹出式窗口控制时是从模式 this.MSG=""; //消息 //-----初始化设置--------------------------------------------------------------------- var TimeOUT=20; var M_Stop=false; var mediaObj=document.getElementById(_mediaid); var showObj=document.getElementById(_showTextid); var SoundID=0; var nextID=1; var MusicLength=0; var Music=new Array(); var ACT; var sTime=TimeOUT; var WinOPEN; var revFlag=false; function duiLei() { var lgh=50 ;//队列长 var sID=new Array(); var num=0; var topn; var lenght=0; this.isTop=true; for(var i=0;ilgh-1)num=0; sID[num]=x; topn=num; } this.output=function() { if(lenght>0) { lenght--; num--; } this.isTop=false; if(numlgh-1)num=0; if(num==topn)this.isTop=true; return sID[num]; } this.GetIsButtom=function() { return lenght==0; } } var His=new duiLei(); this.AddList=function(u,n,f)//add Music { var tmp=(f==undefined)?"no":f; Music[Music.length]={url:u,name:n,file:tmp,id:MusicLength}; MusicLength=Music.length; } function PlayID(c_id) { mediaObj.controls.stop(); mediaObj.URL=Music[c_id].url; mediaObj.controls.play(); } function GetNextID(leg,RandomFlag,isMas) { var temp; if(His.isTop) { if(isMas) { if(RandomFlag) { temp=Math.round(Math.random()*(leg-1)) } else { temp=(SoundID+1)%leg; } }//-------- else { temp=GetMenuPlayNext(leg) } His.input(temp); return temp; } else { return His.popID(); } } function GetMenuPlayNext(length) { if(WinOPEN!=null && WinOPEN.open) { return WinOPEN.GetNextSoundID(); } else { return (SoundID+1)%length; } } function testTimeOut(s) { if(s) { TimeOUT--; if(TimeOUT==0) { TimeOUT=sTime; return true; } else { return false; } } else { TimeOUT=sTime; return false; } } function MsgRefresh()//更新消息 { var staText; staText="当前""+Music[SoundID].name+SoundID+""下一首""+Music[nextID].name+nextID+"""; staText="当前:" +mediaObj.status +"--" +Music[SoundID].name+"--下一首--" +Music[nextID].name+""; //showObj.innerHTML=staText; ////////////////////////////////////////////////////////////////////// showObj.innerHTML=staText; /////////////////////////////////////////////////////////////////////// return staText; } this.RUN=function() { if(MusicLength==0)return; if(!M_Stop && this.CYL) { if(mediaObj.playState==6 && testTimeOut(1)) { this.NEXT(); } if(mediaObj.playState==10||mediaObj.playState==1) { testTimeOut(0); this.NEXT(); } } this.MSG=MsgRefresh(); } ACT=window.setInterval(_objname+".RUN();",3000); /////////////////////////////////////////////////////////////////////////////以下为程序接口 //////////////////////////////////----------播放控制------------------------- this.PLAY=function(s_id)//播放,如果无参数,即播放当前ID,有参数时,播放参数指定的ID { if(mediaObj.URL=="")mediaObj.URL=Music[0].url; if(arguments.length>0) { SoundID=s_id; PlayID(SoundID); } else { mediaObj.controls.play(); } this.MSG=MsgRefresh(); M_Stop=false; this.MASMODE=true; revFlag=false; } this.PAUSE=function()//暂停 { mediaObj.controls.pause(); this.MSG=MsgRefresh(); } this.REV= function(t)//播放上一首 { var idx=1; if(arguments.length>0)idx=t; if(!revFlag)idx++; for(;idx>0;idx--) { if(His.GetIsButtom())return;//没有前一首了 nextID=SoundID; //当带有参数时,将播放向下播放第N首 SoundID=His.output(); } PlayID(SoundID); this.MSG=MsgRefresh(); M_Stop=false;//停止标记 revFlag=true; } this.NEXT=function(t)//播放下一首,当带有参数时, { //将播放向下播放第N首,但只能是历史播放才有些功能 idx=1; if(arguments.length>0)idx=t; if(revFlag)idx++; for(;idx>0;idx--) { SoundID=nextID; nextID=GetNextID(MusicLength,this.RDM,this.MASMODE); if(His.isTop)break; } PlayID(SoundID); this.MSG=MsgRefresh(); M_Stop=false; revFlag=false; } this.STOP=function()//停止播放 { M_Stop=true; mediaObj.controls.stop(); } this.SETVOLUME=function(vol)//设置音量 { if(vol>100)vol=100; if(vol0)return Music[c_id]; return Music[SoundID];//url:歌曲链接地址,name:歌曲名,file:LRC歌词地址(用于以后的功能扩展),id:歌曲的id } this.RESTA=function()//返回播放器状态 { return mediaObj.playState; } //----------外部播放控制接口------------------------- this.MENUPLAY=function(c_id,n_id)//播放,并且设置当前ID,和下一首的ID(作用是用在新开的窗口的接口) { SoundID=c_id; nextID=n_id; PlayID(SoundID); His.input(SoundID); this.MSG=MsgRefresh(); this.MASMODE=false; } this.GetMusicLength=function()//返回曲目总数 { return MusicLength; } this.OPENMUNU=function()//打开歌曲列表 { var url="XBandLH.htm?"+_objname; WinOPEN=window.open(url,"WinList", " width=250, height=300,scrollbars=1 "); } } var oo=new classMedia('media1','show','oo');//第一个参数,播放器ID,第二个参数显示歌词容器ID,第三个参数,所创建的的对象变量名称 oo.AddList('http://qz.gx.vnet.cn/bbs/music/0731/02.wma','情归于尽','qingguiyijin.lrc'); oo.AddList('http://qz.gx.vnet.cn/bbs/music/0318/04.wma','熟能生巧','snsq.lrc'); oo.AddList('http://qz.gx.vnet.cn/bbs/music/0318/06.wma','人质','renzi.lrc'); oo.AddList('http://qz.gx.vnet.cn/bbs/music/0318/09.wma','夜曲','yeqi.lrc'); oo.AddList('http://qz.gx.vnet.cn/bbs/music/0318/10.wma','只对你说','zdns.lrc'); oo.AddList('http://bbs.yc360.net/music/suibianxiaohui.mp3','随便','suibian.txt'); oo.AddList('http://202.195.195.137/music/赵传/爱要怎么说出口.mp3','爱要怎么说出口','ayzmsck.lrc'); oo.AddList('http://ctone.zmcc.com.cn/ColorTone/music/03/01/01/c0301010559.wma','一辈子孤单','ybzgd.lrc'); oo.AddList('http://www.eqdu.com/modules/music/upload/music/200681441498453.mp3','青青河边草','qqhebianchao.lrc'); oo.AddList('http://www.vllan.com/bbs/UploadFile/2006-3/200631610291574926.mp3','在那遥远的地方','znyyddf.txt'); oo.AddList('http://www.badmintonfan.com/mv/cksdxz.mp3','从开始到现在 ','kadxz.lrc'); oo.AddList('http://www.tiantian2006.com/闪亮的日子-罗大佑.mp3','闪亮的日子 ','shanlian.lrc'); oo.AddList('http://www.blogd.cn/UploadFiles/2006-11/1113752996.mp3','菊花台','juhuatai.lrc'); oo.AddList('http://www.cxpre.com/tinguting/uploadfile/20059763413933.wma','莫斯科没有眼泪','mosike.lrc'); oo.AddList('http://down.yysy.net/Music/siledouyaoai.mp3','死了都要爱','xileai.lrc'); oo.AddList('http://maolv.cm310.com/mp3/206.mp3','嘟啊嘟'); oo.AddList('http://www.tt99w.com/dj/djku/kanshangta.mp3','看上她','kanshangta.lrc'); oo.AddList('http://www.nnred.com/bbs/mp3/11.mp3','飘移','piaoyi.lrc'); oo.AddList('http://www.1860tm.com/word/firstlove.mp3','第一次爱的人','diyiciairen.lrc'); oo.AddList('http://online.btvu.org/club/forum/files/307.mp3','爱你','ainiwang.lrc'); oo.AddList('http://www.7say.com/music/fly.wma','隐形的翅膀','yinche.lrc'); oo.AddList('http://www.malamusic.com.tw/ezfiles/mala/img/img/2275/marvin7.mp3','轮回'); oo.INIT();//初始化并开始播放
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
由主页面弹出的菜单页面代码--XBandLH.htm
播放清单 A { COLOR: #334455; TEXT-DECORATION: none } A:link { COLOR: #334455; TEXT-DECORATION: none } A:visited { COLOR: #223344; TEXT-DECORATION: none } A:active { COLOR: #334455; TEXT-DECORATION: none } A:hover { COLOR: gold; TEXT-DECORATION: none } BODY { MARGIN: 0px; CURSOR: crosshair; BACKGROUND-COLOR: #8498a3 } BODY { FONT-SIZE: 9pt; COLOR: #b0c0d0; FONT-FAMILY: 'Tahoma','Verdana','Arial' } TD { FONT-SIZE: 9pt; COLOR: #b0c0d0; FONT-FAMILY: 'Tahoma','Verdana','Arial' } a.redcolor:link,a.redcolor:visited{color:#ff7788;} a.redcolor:hover{color:#FF0000;TEXT-DECORATION:underline; }
|<< < > >>| | |
| |