使用DOM为IE创建视频Flash播放器

时间:2013-06-05 19:28:03

标签: javascript flash internet-explorer dom video

我正在尝试使用javascript来创建视频Flash文件。我正在使用DOM动态创建Flash文件。我正在使用的代码适用于Chrome,但是当我尝试在IE中运行它时,它说它无法加载文件。这是我的代码。

function create(){

var videoFile = "file.mp4";

var flashVideo = document.createElement("object");

    flashVideo.setAttribute("id","videoFlash"); 
    flashVideo.setAttribute("type","application/x-shockwave-flash");    
    flashVideo.setAttribute("data","http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf");  
    flashVideo.setAttribute("width","640"); 
    flashVideo.setAttribute("height","360");

var paramM = document.createElement("param");

    paramM.setAttribute("name", "movie");
    paramM.setAttribute("value", "http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf");

var paramA = document.createElement("param");

    paramA.setAttribute("name", "allowFullScreen");
    paramA.setAttribute("value", "true");

var paramW = document.createElement("param");

    paramW.setAttribute("name", "wmode");
    paramW.setAttribute("value", "transparent");

var paramF = document.createElement("param");

    paramF.setAttribute("name", "flashVars");
    paramF.setAttribute("value", "config={'playlist':[{'url':'" + videoFile + "','autoPlay':true}]}");

flashVideo.appendChild(paramM);
flashVideo.appendChild(paramA);
flashVideo.appendChild(paramW);
flashVideo.appendChild(paramF);

document.getElementById("videoPlayer").appendChild(flashVideo);

0 个答案:

没有答案