/*
* 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播放器模块结束 */