www.gusucode.com > 嘟嘟文章系统 1.0码程序 > movie/js/RelPlayer.js
function getObj(objName) { try { if (document.getElementById) { return eval('document.getElementById("'+objName+'")'); } else { return eval('document.all.'+objName); } } catch(e) {} } function getOLeft(myObj) { curObj = myObj; var objLT = curObj.offsetLeft; while(curObj!=curObj.offsetParent && curObj.offsetParent){ curObj=curObj.offsetParent; if(curObj.tagName=="DIV" || curObj.tagName=="TABLE" || curObj.tagName=="TR" || curObj.tagName=="TD"){ objLT += curObj.offsetLeft; } } return objLT; } //truncation string function trunStr(str) { if (str.length > 12) return str.substr(0,12) + " … "; else return str; } function toPlay() { if (getObj("RelPlayer").GetPlayState() != 3) { if (getObj("RelPlayer").GetPlayState()==4||getObj("RelPlayer").GetPlayState()==0) { getObj("RelPlayer").DoPlay(); //getObj("playControl").src="http://mat1.qq.com/bb/images/playbox/chattingroom2_22.gif"; getObj("play").innerText="暂停"; //getObj("mediaInfo").innerText="缓冲"; } } else { toPause(); getObj("play").innerText="播放"; } } function toPause() { if (getObj("RelPlayer").GetLength() > 0) { infoChange = 1; getObj("RelPlayer").DoPlayPause(); getObj("playControl").src="http://mat1.qq.com/bb/images/playbox/chattingroom2_09.gif"; getObj("statImg").src="http://mat1.qq.com/bb/images/playbox/pause.gif"; getObj("mediaInfo").innerText="已暂停"; } } function toStop() { if (getObj("RelPlayer").GetLength() > 0) { getObj("RelPlayer").DoStop(); getObj("playControl").src="http://mat1.qq.com/bb/images/playbox/chattingroom2_09.gif"; getObj("statImg").src="http://mat1.qq.com/bb/images/playbox/stop.gif"; getObj("mediaInfo").innerText="已停止"; } } function toMute() { if(getObj("RelPlayer").GetMute()==true) { getObj("RelPlayer").SetMute(false); getObj("muteControl").src = "http://mat1.qq.com/bb/images/playbox/chattingroom2_13.gif"; getObj("muteControl").alt = "关闭声音"; } else{ getObj("RelPlayer").SetMute(true); getObj("muteControl").src = "http://mat1.qq.com/bb/images/playbox/chattingroom2_21.gif"; getObj("muteControl").alt = "打开声音"; } } function fullScreen() { try { if(getObj("RelPlayer").GetLength() > 0) { getObj("RelPlayer").SetFullScreen(); } } catch(e) {} } var isPorV = 0; function mouseDown(objSign) { isPorV = objSign; if(isPorV==0){ if(getObj("RelPlayer").GetLength() > 0) { pFlag = true; if(window.event.srcElement.id!="pZone") getObj("pBox").style.left = getObj("pBox").offsetLeft -1; else getObj("pBox").style.left = (window.event.x-12); } } else if(isPorV==1) { vFlag = true; if(window.event.srcElement.id!="vZone") getObj("vBox").style.left = getObj("vBox").offsetLeft; else getObj("vBox").style.left = (window.event.x-3); } } function mouseMove() { if(isPorV==0) { if(getObj("RelPlayer").GetLength() > 0) { if(pFlag) getObj("pBox").style.left = window.event.clientX - getOLeft(getObj("pZone")) - 12 +"px"; if (parseInt(getObj("pBox").style.left.replace("px","")) > pZoneWidth) getObj("pBox").style.left=pZoneWidth +"px"; if (parseInt(getObj("pBox").style.left.replace("px","")) < -5) getObj("pBox").style.left=-5 +"px"; } } else if(isPorV==1) { if(vFlag) getObj("vBox").style.left = window.event.clientX - getOLeft(getObj("vZone")) - 4 +"px"; if (parseInt(getObj("vBox").style.left.replace("px","")) > 56) getObj("vBox").style.left=56 +"px"; if (parseInt(getObj("vBox").style.left.replace("px","")) < 10) getObj("vBox").style.left=10 +"px"; if(isPorV==1) { if (vFlag) { tempVol = (parseInt(getObj("vBox").style.left) -9)*1.7; getObj("RelPlayer").SetVolume(Math.round(tempVol)); } } } } function mouseUp() { if(isPorV==0){ if(getObj("RelPlayer").GetLength() > 0){ if (pFlag){ var duration = getObj("RelPlayer").GetLength(); getObj("RelPlayer").SetPosition(duration * (parseInt(getObj("pBox").style.left)/pZoneWidth)); } pFlag = false; } }else if(isPorV==1){ if (vFlag){ tempVol = (parseInt(getObj("vBox").style.left) -9)*1.7; getObj("RelPlayer").SetVolume(Math.round(tempVol)); } vFlag = false; } } function mouseEnd() { window.event.returnValue = false; } function OnloadFun() { startdrag(); setInterval("FixPos()",1000); } var fFlag= false; //drag func var pFlag = false; var pZoneWidth = 320 - 29; var infoChange = 1; var bufferingProgress; var downloadProgress; var bitRate; var currentPositionString; var mediaTitle; var itemTitle; var mediaInfo = getObj("mediaInfo"); function startdrag() { if(getObj("RelPlayer").GetLength()||(!isNaN(getObj("RelPlayer").GetPosition()))){ window.document.onmousemove = mouseMove; window.document.ondragstart = mouseEnd; window.document.onmouseup = mouseUp; } } function FixPos() { if(getObj("RelPlayer").GetLength()>0) { var duration = getObj("RelPlayer").GetLength(); var pos = getObj("RelPlayer").GetPosition(); if (pos == 0) { var pBoxPos = Math.round(pos/duration*pZoneWidth)+5; } else { var pBoxPos = Math.round(pos/duration*pZoneWidth)+5; } if (!isNaN(pBoxPos)) { getObj("pBox").style.left = pBoxPos; } if(getObj("RelPlayer").GetPlayState() == 0) { getObj("playControl").src="http://mat1.qq.com/bb/images/playbox/chattingroom2_09.gif"; getObj("pBox").style.left = 5; getObj("statImg").src="http://mat1.qq.com/bb/images/playbox/stop.gif"; mediaInfo.innerText="已停止"; } bufferingProgress = getObj("RelPlayer").GetBufferingTimeElapsed(); downloadProgress = parseInt(getObj("RelPlayer").GetBufferingTimeElapsed()); switch(getObj("RelPlayer").GetPlayState()) { case 7: { mediaInfo.innerText="准备就绪"; } break; case 2: { getObj("statImg").src="http://mat1.qq.com/bb/images/playbox/play.gif"; getObj("playControl").src="http://mat1.qq.com/bb/images/playbox/chattingroom2_22.gif"; if ( parseInt(bufferingProgress) > 0 && parseInt(bufferingProgress) < 100 ) { mediaInfo.innerText="缓冲处理: 完成 "+bufferingProgress.toString()+"%"; } else { mediaInfo.innerText="缓冲处理"; } } break; case 3: { getObj("statImg").src="http://mat1.qq.com/bb/images/playbox/play.gif"; getObj("playControl").src="http://mat1.qq.com/bb/images/playbox/chattingroom2_22.gif"; if ( downloadProgress == 0 ) { mediaInfo.innerText="正在播放"; } showPlayInfo(); } break; } } } function showPlayInfo() { if ( infoChange ==1 ) { if ( downloadProgress < 100 ) { mediaInfo.innerText="正在播放: "+downloadProgress.toString()+"% 已下载"; } else { mediaInfo.innerText="正在播放: ... 千比特/秒"; } if ( downloadProgress == 0 ) { mediaInfo.innerText="正在播放"; } } if ( infoChange ==4 ) { mediaInfo.innerText="播放列表: "; } if ( infoChange ==8 ) { mediaInfo.innerText="剪辑: "; } if ( infoChange < 11 ) { infoChange += 1; } else { infoChange = 1; } } OnloadFun();