2011-07-24 31 views
0

我已經得到了以下服務器端的視頻片段變量:$fileName = "bin-debug/Video Source/Black Eyed Peas - The Time.flv";我使用以下JavaScript來創建這個視頻片段的播放器(我使用了Flex視頻組件)Javascript的創建Flash播放器

function createPlayer(videoSource){ 
    document.writeln("<div id=\"player\">"); 
    document.writeln("<object width=\"489\" height=\"414\" FlashVars=\""+videoSource+"\">"); 
    document.writeln("<param name=\"player\" value=\"bin-debug/FlexPlayer.swf\">"); 
    document.writeln("<embed src=\"bin-debug/FlexPlayer.swf\" name=\"player\" width=\"489\" height=\"414\" FlashVars=\""+videoSource+"\">"); 
    document.writeln("</embed>"); 
    document.writeln("</object>"); 
    document.writeln("</div>");    
} 

函數調用就像

<script type="text/javascript"> 
var videoSource = "<?php echo $fileName; ?>"; 
    createPlayer(videoSource); 
</script> 

出於某種原因,不能播放不同的視頻。也許問題出在指定videoSourcew標籤的MXML中?任何幫助將不勝感激。

回答

1

也許這樣

document.writeln("<param name=FlashVars value="+videoSource+">"); 

編輯

然後,你必須定義Flash變量PARAM,但它不是在嵌入稱爲

高度後嵌入添加此= \ 「414 \」

FlashVars=\""+videoSource+"\" 

爲這個結果

document.writeln("<embed src=\"bin-debug/FlexPlayer.swf\" name=\"player\" width=\"489\" height=\"414\" FlashVars=\""+videoSource+"\">"); 
+0

仍然不會播放不同的視頻 – George

+0

運行Google Chrome Inspect元素後,我看到param標籤如下所示: George

+0

我在inspect元素後編輯了上面的代碼,它看起來不錯,但播放器中的視頻不會改變 – George