广 告 位 置 |
|
|
 |
站 内 搜 索 |
|
|
 |
|
|
|
|
网页插入real播放器多文件可选择播放的JS代码
来源:盛绿设计 等级:默认等级
发布于2006-09-06 10:25 被读70次 【字体:大 中 小】
|
|
把下面的代码存成js文件,在网页里引入。 然后用JS方式调用,可以在网页里插入real播放器,并且可以通过方法参数设置多个文件,高,宽,是否自动播放! GamVanPlayer_real(w, h, auto, path) 蓝色部分参数w 代表播放器宽度 h表示高度 auto为0则不自动播放 -1表示自动播放 path文件路径,多个文件需要用单竖线分开,例如
<script language="javascript"> GamVanPlayer_real(450, 320, -1, "http://club.gamvan.com/1.rm|http://club.gamvan.com/2.rm") </script> 这个方法比较适合论坛UBB转换时用到,动态语言里只需要生成调用这个函数的JS语句 而网页里引入下面这个JS即可。
/* * Created on 2006-2-22 * Last modified on 2006-02-23 * Powered by www.GamVan.com */
/* Real播放器模块开始 */ function Do_play(id){ //播放 var the_player = document.getElementById(id); the_player.DoPlay(); }
function Do_stop(id){ //停止 var the_player = document.getElementById(id); the_player.DoStop(); }
function GamVanPlayer_realPlayer(id){ id = "RAOCX" + id; var the_player = document.getElementById(id); Do_stop(id); the_player.SetSource(document.getElementById("mediaPath").value); Do_play(id); }
function MediaChange(rom, path){ path = path.replace(" "," "); document.all["mediaPath"].value=path; GamVanPlayer_realPlayer(rom); }
function GamVanPlayer_real(w, h, auto, path){ var ss = new Array(); ss = path.split("|"); var number = ss.length; //判断文件地址个数 var rom = Math.random(); rom = rom * 1000000000; rom = Math.ceil(rom); var str = ("<OBJECT classid=clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA class=OBJECT id=RAOCX"+rom+" width=\""+w+"\" height=\""+h+"\">"); str += ("<PARAM NAME=SRC VALUE="+ ss[0] +">"); str += ("<PARAM NAME='CONSOLE' VALUE='realplayer"+rom+"'>"); str += ("<PARAM NAME=CONTROLS VALUE=imagewindow><PARAM NAME=AUTOSTART VALUE='"+ auto +"'></OBJECT>"); str += ("<br>"); str += ("<OBJECT classid='CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA' height='32' id='video"+rom+"' width='"+w+"'>"); str += ("<PARAM NAME=SRC VALUE="+ ss[0] +">"); str += ("<PARAM NAME='AUTOSTART' VALUE='"+ auto +"'>"); str += ("<PARAM NAME='CONTROLS' VALUE='controlpanel'>"); str += ("<PARAM NAME='CONSOLE' VALUE='realplayer"+rom+"'>"); str += ("</OBJECT><br>"); str += ("<input type=\"button\" name=\"mplayer"+ rom +"\" onclick=\"javascript:real_full('"+rom+"')\" value=\"全屏播放\" class=\"btn\" />"); str += " "; if(number>0){ //如果不止一个播放地址 str += ("<select name=\"mediaList\" onChange=\"MediaChange("+rom+",mediaList.options[selectedIndex].value);\">"); str += ("<option value=\"\" >播放列表</option>"); for(var i=0; i<ss.length; i++){ str += ("<option value="+ ss[i] +">文件["+(i+1)+"]</option>"); //alert(ss[i]); } str += "</select>"; }
str += ("<input type=\"hidden\" name=\"mediaPath\" value=''/>"); document.write(str); } function real_full(r){ var id = "RAOCX" + r; if(!document.all[id].CanStop()){ alert('影片未开始,无法全屏!'); }else{ alert('将进入全屏模式,按Esc键退出全屏!'); document.all[id].SetFullScreen(); } } /* Real播放器模块结束 */
|
相关专题:暂无相关专题
上一篇:iframe嵌入网页的用法 下一篇:提高网页中GOOGLE广告显示速度的代码
|
共有评论 0 条 网友评分 查看全部
|
|
|