Possible Duplicate:
Change flash src with jquery?
EDIT I figured out the first issue (not loading at all) so I took that portion out
I have a flashplayer that I make like so:
<div id="video_content"><div id="flash_wrapper">
<object classid="MyID" width="402" height="285" id="videoplayer" align="middle">
<param name="movie" value="videoplayer.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="FlashVars" value="screencast_url=myVideo.flv" id="flash" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="videoplayer.swf" width="402" height="285">
<param name="movie" value="videoplayer.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<param name="FlashVars" value="screencast_url=myVideo.flv" id="flash" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
I have buttons that I want to use to change the video playing. The js method to change videos looks like this:
function ChangeVideo(videoIndex) {
//Video Location String
var vidLocation = "screencast_url=";
//Determines what video to load
switch (videoIndex) {
case 1:
//Change Video Location
vidLocation += "myVideo.flv";
break;
case 2:
//Change Video Location
vidLocation += "myVideo2.flv";
break;
case 3:
//Change Video Location
vidLocation += "myVideo3.flv";
break;
case 4:
//Change Video Location
vidLocation += "myVideo4.flv";
break;
}
//Change value of flashplayer FlashVar
$('#flash').val(vidLocation);
}
The video looks to have loaded correctly and all the information seems to be correct, but the video will not play when I hit the play button (Current video keeps playing).
How would you load another video into a flash player after it has been loaded?
EDIT2 If I try this:
//Creates empty values
var flashvars = vidLocation;
var params = {};
var attributes = {};
//Change video
swfobject.embedSWF("videoplayer.swf", "video_content", "300", "120", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
Instead of :
//Change value of flashplayer FlashVar
$('#flash').val(vidLocation);
Which seems to reload the player now, but it still does not play.
FlashVars are only loaded when the movie initially loads, so you can’t update the video url just by updating the DOM attributes. I recommend using swfObject’s “dynamic” loading method to load the new videos via javascript.