Search code examples
phpflashflashvars

Javascript-Create Flash player


I've got the following server-side videoclip variable: $fileName = "bin-debug/Video Source/Black Eyed Peas - The Time.flv"; I'm using the following Javascript to Create the Player with this videoclip(I'm using the Flex Video component)

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>");               
}

The function call is like

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

For some reason the Player isn't playing different videos. Maybe the problem is in the MXML where videoSourcew tag is specified? Any help will be greatly appreciated.


Solution

  • Maybe like this

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

    ?

    EDIT

    Then you have define the FlashVars param but it's not called in the embed

    Add this in the embed after height=\"414\"

    FlashVars=\""+videoSource+"\"
    

    for this result

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