jwplayer 在 drupal 页面中无法识别
我已在我的 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
知道了。
script
必须在div
下面进行描述,所以我只使用了drupal_add_js("javascript code", 'inline', 'footer');
而不是drupal_add_js("javascript code", 'inline');
,因为如果未指定,第三个参数默认为'header'
。Got it. The
script
must be described below thediv
, so I just useddrupal_add_js("javascript code", 'inline', 'footer');
instead ofdrupal_add_js("javascript code", 'inline');
, because the third parameter defaults to'header'
if not specified.