开发者

jwplayer not recognized in a drupal page

开发者 https://www.devze.com 2023-03-21 17:44 出处:网络
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.

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.

jwplayer not recognized in a drupal page


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.

0

精彩评论

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

关注公众号