jwplayer 在 drupal 页面中无法识别

发布于 2024-11-25 12:22:26 字数 1229 浏览 1 评论 0原文

我已在我的 drupal 网站节点之一中插入了 jwplayer,但我无法使用 Javascript API。我使用示例 从这里,我尝试嵌入它并从 Javascript 进行设置。

这是我的模块的 hook_nodeapi 的序列:

case 'view':
  // irrelevant code
  $node->content['body'] = array (
    '#value' => "<div id='player'>Loading the player ...</div>",
    '#weight' => 9,
  );
  drupal_add_js('sites/all/libraries/mediaplayer-5.7/jwplayer.js', 'file');
  drupal_add_js('sites/all/libraries/mediaplayer-5.7/swfobject.js', 'file');
  drupal_add_js("jwplayer('player').setup({
    flashplayer: 'http://localhost:8088/sites/all/libraries/mediaplayer-5.7/player.swf',
    file: 'http://localhost:8088/" . $node->field_video[0]['filepath'] . "',
    height: 270,
    width: 480
  });", 'inline');
break;

这两个 javascript 文件已成功附加到 drupal 页面的 HTML 输出,并且 div 也出现,但是当涉及内联脚本时,我收到错误,因为 jwplayer不被识别。我扫描了一些参考资料,发现问题可能出在Flash安全问题上,所以我进入Flash Player的全局设置->高级->受信任的位置设置,我还添加了我的player.swf、站点网址和jwplayer 的整个目录。但一切都没有改变。

我该如何解决这个问题?会欣赏任何想法。

脚本错误的控制台日志

I've inserted a jwplayer in one of my drupal website node but I can't use Javascript API. I work with examples from here, and I tried to embed it and to setup from Javascript as well.

Here is a sequence of my module's hook_nodeapi:

case 'view':
  // irrelevant code
  $node->content['body'] = array (
    '#value' => "<div id='player'>Loading the player ...</div>",
    '#weight' => 9,
  );
  drupal_add_js('sites/all/libraries/mediaplayer-5.7/jwplayer.js', 'file');
  drupal_add_js('sites/all/libraries/mediaplayer-5.7/swfobject.js', 'file');
  drupal_add_js("jwplayer('player').setup({
    flashplayer: 'http://localhost:8088/sites/all/libraries/mediaplayer-5.7/player.swf',
    file: 'http://localhost:8088/" . $node->field_video[0]['filepath'] . "',
    height: 270,
    width: 480
  });", 'inline');
break;

The two javascript files are successfully appended to drupal page's HTML output, and the div appears too, but when it comes to the inline script, I get an error because jwplayer is not recognized. I scanned some references and I found out that the problem might be in a Flash security issue, so I went to Flash Player's Global Settings -> Advanced -> Trusted Location Settings and I added my player.swf, the site web address and the whole directory of jwplayer as well. But nothing changed.

How can I solve this problem? Will appreciate any ideas.

Console log of the script error

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

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

发布评论

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

评论(1

趁年轻赶紧闹 2024-12-02 12:22:26

知道了。 script 必须在 div 下面进行描述,所以我只使用了 drupal_add_js("javascript code", 'inline', 'footer');而不是 drupal_add_js("javascript code", 'inline');,因为如果未指定,第三个参数默认为 'header'

Got it. The script must be described below the div, so I just used drupal_add_js("javascript code", 'inline', 'footer'); instead of drupal_add_js("javascript code", 'inline');, because the third parameter defaults to 'header' if not specified.

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