网页插入real播放器多文件可选择播放的代码 2006-6-9-1

网页插入real播放器多文件可选择播放的代码
把下面的代码存成js文件,在网页里引入。
然后用JS方式调用,可以在网页里插入real播放器,并且可以通过方法参数设置多个文件,高,宽,是否自动播放!
GamVanPlayer_real(w, h, auto, path)
蓝色部分参数w 代表播放器宽度 h表示高度 auto为0则不自动播放 -1表示自动播放
path文件路径,多个文件需要用单竖线分开,例如
<script language="javascript">
GamVanPlayer_real(450, 320, -1, "01.rmvb|02.rmvb")
</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 +"/" οnclick=/" 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播放器模块结束 */

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值