开发者

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

开发者 https://www.devze.com 2022-12-15 05:22 出处:网络
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.开发者_StackOverflow社区 One window o

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.开发者_StackOverflow社区 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消