未捕获的错误:调用 NPObject 上的方法时出错

发布于 2024-12-27 18:34:24 字数 1377 浏览 3 评论 0原文

我的页面上有一个 Flash 视频,如下所示:

<script type="text/javascript">
var flashvars = {
};
var params = {
    movie: "VideoMain.swf",
    quality: "high",
    bgcolor: "#000000",
    allowScriptAccess: "always",
    wmode: "transparent"
};
var attributes = {
  id: "VideoMain",
  name: "VideoMain",
  classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  width: "100%",
  height: "100%"
};
swfobject.embedSWF("./video/VideoMain.swf", "myVideoContent", "100%", "100%", "11.0.0","", flashvars, params, attributes);
</script>

<div id="myVideoContent">
    <h1>Oooppsss....you need flash or a newer version of flash</h1>
    <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>

上面的内容被附加到 #VideoMain

然后我有以下内容:

$('#X.click').click(function(e) {
    var flash = document.getElementById("VideoMain");
    flash.sendToActionScriptPublishVideo(true);
});

失败并出现控制台错误:

Uncaught Error: Error calling method on NPObject.
(anonymous function)
jQuery.event.dispatchjquery.js:3256
jQuery.event.add.elemData.handle.eventHandlejquery.js:2875

任何想法可能是什么这里错了?谢谢

I have a flash video on my page as follows:

<script type="text/javascript">
var flashvars = {
};
var params = {
    movie: "VideoMain.swf",
    quality: "high",
    bgcolor: "#000000",
    allowScriptAccess: "always",
    wmode: "transparent"
};
var attributes = {
  id: "VideoMain",
  name: "VideoMain",
  classid: "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  width: "100%",
  height: "100%"
};
swfobject.embedSWF("./video/VideoMain.swf", "myVideoContent", "100%", "100%", "11.0.0","", flashvars, params, attributes);
</script>

<div id="myVideoContent">
    <h1>Oooppsss....you need flash or a newer version of flash</h1>
    <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>

The above gets appended into #VideoMain

Then I have the following:

$('#X.click').click(function(e) {
    var flash = document.getElementById("VideoMain");
    flash.sendToActionScriptPublishVideo(true);
});

This fails with the console error:

Uncaught Error: Error calling method on NPObject.
(anonymous function)
jQuery.event.dispatchjquery.js:3256
jQuery.event.add.elemData.handle.eventHandlejquery.js:2875

Any ideas what could be wrong here? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦过后 2025-01-03 18:34:24

NPObject 是通过浏览器公开的任何“外部”代码的“接口”(外部,如对于 JavaScript 来说是外来的,否则它可能是浏览器自己的对象,例如全局 window 对象)。嵌入式 Flash 插件肯定会实现这个“接口”(因此浏览器将其视为另一个 NPObject)。

当您调用该对象上的方法时,有几个函数包装该调用,序列化传递到该对象并返回到浏览器运行时的数据。很难确定到底是什么不起作用,但一些常见的原因包括:

  1. 该插件没有公开(或尚未注册)具有您尝试调用的名称的方法。
  2. 该插件以不允许跨脚本的方式嵌入(限制可能是双方的,Flash 要求调用来自受信任的域,并且您可以通过对象标记中的设置限制插件与环境通信
  3. 。通过 JavaScript 调用的插件代码中抛出的错误 - 我不确定这是否是相同的错误,但很有可能。

NPObject is an "interface" to any "foreign" code exposed through the browser (foreign, as in foreign to JavaScript, otherwise it may be browser's own objects, like the global window object for example). The embedded Flash plugin would certainly implement this "interface" (so the browser sees it as just another NPObject).

When you call a method on that object, there are several function that wrap that call serializing the data passed to the object and back to browser's runtime. It is difficult to tell for certain what exactly didn't work, but some common reasons would include:

  1. The plugin does not expose (or did not register yet) a method with the name you are trying to call.
  2. The plugin was embedded in a way that crosscripting is not allowed (the limitations may be on both sides, Flash requires that the call comes from a trusted domain and you may restrict the plugin from communicating with environment through the settings in the object tag.
  3. An error thrown in the plugin's code invoked through JavaScript - I'm not sure that would be the same error, but it is very much likely.
始于初秋 2025-01-03 18:34:24

我收到了同样的错误消息。仅当 Flash 进行外部接口调用并在 Flash 崩溃(无论出于何种原因)后返回时,才会出现此问题。我实施的修复是:检查 Flash 对象是否仍在运行,以及回调是否仍然是该对象的函数。

I was getting the same error message. The problem only occurred when Flash made an ExternalInterface call that returned after Flash crashed (for what reason whatsoever). The fix I implemented was: Check if the Flash object is still up and running and if the callback is still a function of that object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文