简体   繁体   English

SoundManager2 SWF加载问题

[英]SoundManager2 SWF Load Issue

Trying to load Soundmanager2's SWF file from our CDN. 试图从CDN加载Soundmanager2的SWF文件。 I assume I'm running into cross domain flash issues. 我认为我遇到了跨域闪存问题。 has anybody done this? 有人这样做吗? it is even possible? 甚至有可能吗?

here's what I'm trying... 这是我正在尝试的...

var allowxdomainscripting = true;
var xdomain = "*";
soundManager.url = 'http://cdn.mycompany.com/inc/soundmanager2.swf';

there's a very obscure reference to this in the documentation, but it's pretty vague... 在文档中对此有一个非常模糊的引用,但这是非常模糊的...

http://www.schillmania.com/projects/soundmanager2/doc/generated/src/SoundManager2_AS3.html http://www.schillmania.com/projects/soundmanager2/doc/generated/src/SoundManager2_AS3.html

any help is appreciated. 任何帮助表示赞赏。

I ran into this as well at one point. 我也曾经碰到过这一点。 SoundManager2 now comes with cross-domain versions of the swf files. SoundManager2现在带有swf文件的跨域版本。

They are zipped up in swf/soundmanager2_flash_xdomain.zip 将它们压缩在swf / soundmanager2_flash_xdomain.zip中

https://github.com/scottschiller/SoundManager2/tree/master/swf https://github.com/scottschiller/SoundManager2/tree/master/swf

Simply unzip and replace with the standard .swf files provided with SoundManager2 and your problem should go away. 只需解压缩并替换为SoundManager2随附的标准.swf文件,您的问题就可以解决。

THANK YOU VERY MUCH! 非常感谢你!

I stumbled upon this answer by total chance after wasting a couple of hours trying to get SM2 SWF embed to work. 在浪费了几个小时试图使SM2 SWF嵌入工作之后,我偶然地偶然发现了这个答案。

I'm going to "revive" this to add a few keywords so Google indexes this answer... Maybe the next person trying to embed SoundManager2 SWF in a cross-domain environment gets it done a little quicker than I did :) 我将“重新激活”该命令以添加一些关键字,以便Google将此答案编入索引...也许下一个试图在跨域环境中嵌入SoundManager2 SWF的人比我做起来要快一点:)

The error I was getting upon flash initialization was: Error calling method on NPObject 我在闪存初始化时遇到的错误是: 在NPObject上调用方法出错

On the JS side, this was the code that broke everything: 在JS方面,这是破坏一切的代码:

// attempt to talk to Flash
flash._externalInterfaceTest(false);     <- KABOOM!

NPObject errors might have many meanings, but more often than not (in our environment) it means: You're trying to call the ExternalInterface through JS on a flash movie hosted on a different domain. NPObject错误可能有多种含义,但是(在我们的环境中)它通常具有以下含义: 您正试图通过JS在不同域上托管的Flash电影上调用ExternalInterface。

After a while I popped open SoundManager2 ActionScript 3 code and saw this: 一段时间后,我弹出了SoundManager2 ActionScript 3代码,并看到了以下内容:

public var allow_xdomain_scripting:Boolean = false;
public var xdomain:String = "*";

[... other stuff ...]

if (allow_xdomain_scripting && xdomain) {
    Security.allowDomain(xdomain);
    version_as += ' - cross-domain enabled';
}

Of course that means that the movie that you might be using (no matter if it's debug or not) will not be accessible from a different domain (a CDN, or whatever). 当然,这意味着您可能正在使用的电影(无论是否调试)都无法从其他域(CDN或任何其他域)访问。

The solution was –as stated in @amlutz160's answer– to use the files contained in swf/soundmanager2_flash_xdomain.zip, which are compiled with allow_xdomain_scripting = true . 如@ amlutz160的回答所述,解决方案是使用swf / soundmanager2_flash_xdomain.zip中包含的文件,这些文件是通过allow_xdomain_scripting = true编译的

Posting this is quite embarrassing, and the solution is obvious , but I lost quite a bit of time with this and AFAIK the contents of that mysterious zip file are not documented anywhere (I found a tangential mention on SM2 forums ). 发布此消息非常令人尴尬,并且解决方案很明显 ,但是我为此和AFAIK浪费了很多时间,该神秘zip文件的内容在任何地方都没有记录(我在SM2论坛上找到了切线的提法 )。

PS: I'm forwarding this answer to Scott Schiller so maybe he can update SoundManager2 docs a little bit :P PS:我正在将此答案转发给Scott Schiller,所以也许他可以更新SoundManager2文档:P

Regards! 问候!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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