Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update flashvars and reload flash with jQuery

I would like to update the flashvars value argument to view another video:

<param name='flashvars' value='movieId=1002' />

I found out that I can make it work in Firefox by updating the parameter with the extra step of readding the whole flash contents.

$("param[name=flashvars]").attr("value", "movieId=33");
$("embed").attr("flashvars", "movieId=33");
$(".root").append($("#video"));

But this does not work in IE8 as the browser won't refresh the flash contents. Any ideas on how to reload the flash contents without external dependencies like swfobject.js?

like image 733
Daniel O Avatar asked Oct 05 '10 07:10

Daniel O


2 Answers

// update flashvars
var fv = 'foobar=1';

$("object param[name='flashvars']").attr("value", fv);
$("embed").attr("flashvars", fv);

// create new object to hold it     
var obj = $("object");

// remove existing Flash from DOM
$("object").remove();

// add new HTML to DOM
$("#mviewer").append(obj.html());
like image 76
cloakedninjas Avatar answered Oct 10 '22 01:10

cloakedninjas


I'm curious about this too. I'm trying to send a new string via flashvars to a SWF that I have no opportunity to change, and just changing the flashvars with jQuery, without having to use externalinterface, is the best option.

like image 22
Benjamin Allison Avatar answered Oct 10 '22 00:10

Benjamin Allison