简体   繁体   中英

Trying to access Flash movie from JS works in FF, but not in IE

I am setting up a Flash based MP3 player control (The standalone version of WordPress Standalone Player ). I have a situation of multiple windows with players open. One window opens the other, so I have the window.opener property available.

When the child window is opened, I want to programmatically mute the audio player in the parent window.

This works in Firefox, but not in IE 7 and 8. I know little about Flash/Javascript interaction and I'm stuck. I am not getting any error messages.

To do this, the player SWF object has a setVolume() and close() function. These functions are not defined anywhere in Javascript so I guess that those are provided by the Flash object. This is supported by the following lines I found in the Flash source code of the player:

if (ExternalInterface.available) {
 ExternalInterface.addCallback("load", Application, Application.ei_loadFile);
 ExternalInterface.addCallback("close", Application, Application.ei_closePlayer);
 ExternalInterface.addCallback("open", Application, Application.ei_openPlayer);
 ExternalInterface.addCallback("setVolume", Application, Application.ei_setVolume);    

In Firefox, this works:

if (typeof(AudioPlayer) != "undefined") 
var player = AudioPlayer.getPlayer("audioplayer_1");  // This shows up as 
                                                      // the player SWF object 
                                                      // in Firebug

if (player)
 if (typeof(player.setVolume) == "function")
  player.close();  // This works in FF but not in IE

but in IE, it doesn't. Is this because the callback is not available in IE? Or is there anything I need to do in addition?

If it works in FF but not IE, then the issue is likely in the JavaScript code. ExternalInterface is pretty reliable (99% of the failures I encounter are a result of JavaScript issues, not ActionScript issues). Is window.opener supported in IE? Have you tested your JavaScript in a page without the Flash stuff to make sure the code works?

edit: how do I post this as a comment and not an answer??

edit edit: nvm, I am not cool enough yet to comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM