|
 
升级   50.67% - 注册时间
- 2005-7-4
- 威望
- 65
- 阅读权限
- 30
- 积分
- 352
- 帖子
- 75
- 精华
- 0
- UID
- 32227
- 状态
- 当前离线
|
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>播放器</title>
- </head>
- <script language="javascript">
- //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;i<lgh;i++)
- {
- sID[i]=0;
- }
- this.input=function(x)
- {
- num++;
- lenght++;
- if(num>lgh-1)num=0;
- sID[num]=x;
- topn=num;
- }
- this.output=function()
- {
- if(lenght>0)
- {
- lenght--;
- num--;
- }
- this.isTop=false;
- if(num<0)num=lgh-1;
- return sID[num];
- }
- this.popID=function()
- {
- num++;
- lenght++;
- if(num>lgh-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="<font color=yellow size='2'>当前:</font><font color=#00ffff size='2'>"
- +mediaObj.status
- +"</font><font color=#ff0000 size='2'>--"
- +Music[SoundID].name+"--</font> <a href='#huangXiangBin' onclick='"+_objname+".NEXT()'><font color=#00ff00 size='2'>下一首--</font></a><font color=#ff00ff size='2'>"
- +Music[nextID].name+"</font> ";
- //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(vol<0)vol=0;
- mediaObj.settings.volume=parseInt(vol);
- }
- //----------播放设置-------------------------
- this.SETRDM=function()//设置无序或是有序播放,调用一次,改变一次状态
- {
- this.RDM=this.RDM?false:true;
- }
- this.SETCYCLE=function()//设置是否进行循环播放,调用一次,改变一次状态
- {
- this.CYL=this.CYL?false:true;
- }
- this.INIT=function()
- {
- if(this.RDM==true)//无序播放
- {
- SoundID=GetNextID(MusicLength,this.RDM,this.MASMODE);
- nextID==GetNextID(MusicLength,this.RDM,this.MASMODE);
- }
- if(!M_Stop)
- {
- PlayID(SoundID);
- }
- }
- //----------传输播放状态-------------------------
- this.SENDLRC=function(c_id)//无参数时读取当前歌曲的内容,如果有参数,则读取指定参数歌曲的内容
- {
- if(arguments.length>0)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 ");
- }
- }
- </script>
- <body bgcolor=#000000>
- <div id=show></div>
- <input type="button" name="Submit" value="播放" onclick="oo.PLAY();"/>
- <input type="button" name="Submit2" value="上一首" onclick="oo.REV();" />
- <input type="button" name="Submit3" value="下一首" onclick="oo.NEXT();" />
- <input type="button" name="Submit0" value="停止" onclick="oo.STOP();" />
- <input type="button" name="Submit4" value="打开歌曲列表" onclick="oo.OPENMUNU();" />
- <input type="button" name="Submit5" value="随机/顺序" onclick="oo.SETRDM();" />
- <input type="button" name="Submit5" value="连续/单曲" onclick="oo.SETCYCLE();" />
- <object id='media1' classid=CLSID:6BF52A52-394A-11D3-B153-00C04F79FAA6 width='400' height='100'>
- <param NAME='URL' VALUE=''>
- <param NAME='rate' VALUE='-1'>
- <param NAME='balance' VALUE='0'>
- <param NAME='currentPosition' VALUE='0'>
- <param NAME='defaultFrame' VALUE=''>
- <param NAME='playCount' VALUE='1'>
- <param NAME='autoStart' VALUE='-1'>
- <param NAME='currentMarker' VALUE='0'>
- <param NAME='invokeURLs' VALUE='-1'>
- <param NAME='baseURL' VALUE=''>
- <param NAME='volume' VALUE='100'>
- <param NAME='mute' VALUE='0'>
- <param NAME='uiMode' VALUE='mini'>
- <param NAME='stretchToFit' VALUE='0'>
- <param NAME='windowlessVideo' VALUE='0'>
- <param NAME='enabled' VALUE='-1'>
- <param NAME='enableContextMenu' VALUE='0'>
- <param NAME='fullScreen' VALUE='0'>
- <param NAME='SAMIStyle' VALUE=''>
- <param NAME='SAMILang' VALUE=''>
- <param NAME='SAMIFilename' VALUE=''>
- <param NAME='captioningID' VALUE=''>
- <param NAME='enableErrorDialogs' VALUE='0'>
- <param NAME='_cx' VALUE='5080'>
- <param NAME='_cy' VALUE='5080'>
- </object>
- </body>
- <script language="javascript">
- 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();//初始化并开始播放
- </script>
- </html>
复制代码运行代码另存代码 |
|