Here’s the situation i’m currently facing.
I have an embedded youtube video as <object>. The object exposes javascript API to controle the player.
After setting display:none to the object or the div wrapping the object, the methods become undefined.
Once dispay css property is set back to ‘block’ – the methods become available again.
I’ve created a Fiddle showcasing the problem.
I’d like to know why is it happening, and is it possible to monitor object’s state and see if its already loaded and ready to use?
Thanks ahead!
NOTE: The problem can be seen in Chrome
This happens when using the NPAPI plugin (i.e. not Internet Explorer). You can either move the item off-screen (requires
display:absolute/display:relative), or set the flash object to be 100% size of containing html element and to set the height or width of that element to .01px. Don’t use$(elem).fadeOutbecause at the end of the animation, jq setsdisplay:none. Instead use$(elem).fadeTowhich doesn’t alter other css attributes. It was also necessary to add a new paramto get the fade animation to work.
http://jsfiddle.net/ynuMT/4/