var BarNum, Timer1; Dragging=false; urls=new Array(); urlid=0; playnext=false; function getobj(n) { if (document.getElementById) return document.getElementById(n); else return eval("document.all."+n); } function clearTimer() { clearInterval(Timer1); } function setTimer() { clearTimer(); Timer1=setInterval("playing()", 1000); } function showtip(h) { var tip=getobj("mediaInfo"); if (tip) tip.innerHTML=h; } function openStateChange1(NewState) { switch (NewState) { case 10: showtip("Linking..."); break; case 12: showtip("Opening..."); break; case 16: showtip(""); break; } } function playStateChange1(NewState) { switch (parseInt(NewState)) { case 0: showtip('Unknow'); break; case 1: showtip('Stop'); window.setTimeout("playnextmedia()", 1000); break; case 2: showtip('Pause'); clearTimer(); break; case 3: showtip("Playing..."); var sl=getobj("WMPlayer").currentMedia.duration.toFixed(0); if (sl>0) setTimer(); break; case 4: break; case 6: window.setTimeout('buffering()',900); break; case 7: showtip('waiting...'); break; case 8: showtip('Stop'); clearTimer(); playnext=true; break; case 10: clearTimer(); break; default: break; } } function buffering() { if (document.WMPlayer.playState==6) { var bp=getobj("WMPlayer").network.bufferingProgress; if (bp==100) bp=99; bptimer = window.setTimeout("buffering()",900); } } function playing() { var cp=WMPlayer.controls.currentPosition.toFixed(0); var sl=WMPlayer.currentMedia.duration.toFixed(0); var tip=getobj("mediaInfo"); var t=getobj("ctime"); var p=getobj("ProgressBar1"); var pb=getobj("pbar"); var pn=getobj("pbutton"); if (t) { t.innerText=s2hms(cp)+"/"+s2hms(sl); } if (sl>0 && p) { var w=cp*310/sl; p.style.width=w.toFixed(0)+"px"; } if (sl>0 && pb && pn && !Dragging) { var percent = Math.round((cp/sl)*(pb.clientWidth-pn.clientWidth)); if (!isNaN(percent)) pn.style.left = percent+"px"; } } function s2hms(s) { var h=(s-s%3600)/3600; s%=3600; if (h<10) h="0"+h; var m=(s-s%60)/60; if (m<10) m="0"+m; s%=60; if (s<10) s="0"+s; if (h>0) return(h+":"+m+":"+s); else return(m+":"+s); } function volumeplus(n) { WMPlayer.settings.Volume=WMPlayer.settings.Volume+n; var o=document.getElementById("volumeInfo"); if (o) o.innerHTML="音量"+WMPlayer.settings.Volume+"%"; } function mousedown(n) { BarNum=n; var fa, son; if (BarNum==0) { fa=getobj("pbar"); son=getobj("pbutton"); } else if (BarNum==1) { fa=getobj("vbar"); son=getobj("vbutton"); } Dragging = true; var l=(window.event.srcElement.id!=fa.id)?son.offsetLeft:(window.event.x-Math.floor(son.clientWidth/2)); l=(l<0)?0:l; l=((l+son.clientWidth)>fa.clientWidth)?(fa.clientWidth-son.clientWidth):l; son.style.left=l; } function mousemove() { if (BarNum==0) { fa=getobj("pbar"); son=getobj("pbutton"); } else if (BarNum==1) { fa=getobj("vbar"); son=getobj("vbutton"); } if (Dragging) { var l=window.event.clientX - fa.offsetLeft - son.clientWidth/2; l=(l<0)?0:l; l=((l+son.clientWidth)>fa.clientWidth)?(fa.clientWidth-son.clientWidth):l; son.style.left = l; } if (BarNum==1) getobj("WMPlayer").settings.Volume=100*(parseInt(getobj("vbutton").style.left)/(getobj("vbar").clientWidth-getobj("vbutton").clientWidth)); } function mouseup() { if (BarNum==0) { if (getobj("WMPlayer").currentMedia.Duration>0 && Dragging) getobj("WMPlayer").controls.CurrentPosition=getobj("WMPlayer").currentMedia.Duration*(parseInt(getobj("pbutton").style.left)/(getobj("pbar").clientWidth-getobj("pbutton").clientWidth)); } Dragging=false; } function setvolume(vol) { if (vol<0) vol=0; if (vol>100) vol=100; getobj("WMPlayer").settings.Volume=vol; getobj("vbutton").style.left=vol*(getobj("vbar").clientWidth-getobj("vbutton").clientWidth)/100; } function setsource(url) { var p=getobj("WMPlayer"); if (p) { p.URL=url; p.controls.play(); } } function dostop() { var wmp=getobj("WMPlayer"); if (wmp) wmp.controls.stop(); } function doplay() { var wmp=getobj("WMPlayer"); if (wmp && wmp.URL) { wmp.controls.play(); } } function dopause() { var wmp=getobj("WMPlayer"); if (wmp) wmp.controls.pause(); } function playnextmedia() { if ((playnext==true) && urls && (urls.length>0)) { playnext=false; urlid++; if (urlid>=urls.length) urlid=0; setsource(urls[urlid]); } } window.document.onmousemove = mousemove; window.document.onmouseup = mouseup;