Error: VideoJS is not defined
Source File: http://video.d7x.dev/sites/video.d7x.dev/modules/media-players/videojs/t...
Line: 12

Browser FF5 (OSX)
Drupal 7.7
Video JS 7.x-1.3

CommentFileSizeAuthor
#7 videojs-js_order-1235452-7.patch1.41 KBbradjones1

Comments

drupa11y’s picture

Library: video-js-2.0.2

drupa11y’s picture

Error is also for latest git-checkout & 7.x-dev.

drupa11y’s picture

On pages with a cck-file or video-field and a file ".mov" (h264 codec), player is displayed black and with a file ".m4v", no player is visible I get the following notice:

Notice: Undefined offset: 0 in template_preprocess_videojs() (line 78 of /Applications/MAMP/htdocs/drupal-7.x/sites/video.d7x.dev/modules/media-players/videojs/includes/videojs.theme.inc).

With a file ".mp4" no notice is displayed.

drupa11y’s picture

post #3 is for latest git checkout

gagarine’s picture

#3 #4 has nothing to do with this issue.

This error arrive because VideoJS.setupAllWhenReady(); need to be done *after* video.js is loaded. Check in the .module the function videojs_add();

Btw for one line I think it will be better to add the JS inline instead of loading a external file.

Her mine. I don't make a patch now because I think stuff has to be rewrite differently.

function videojs_add($add = TRUE) {
  static $added = FALSE;

  $directory = variable_get('videojs_directory', 'sites/all/libraries/video-js');
  $return = FALSE;
  if (file_exists($directory . '/video.js')) {
    $lib_videojs_js = $directory . '/video.js';
    $lib_videojs_css = $directory . '/video-js.css';
  }

  if (isset($lib_videojs_js)) {
    $videojs_js = drupal_get_path('module', 'videojs') . '/theme/videojs.js';
    $videojs_css = drupal_get_path('module', 'videojs') . '/theme/videojs.css';
    $settings = array('videojs' => array(
        'autoPlay' => (int) variable_get('videojs_autoplay', ''),
        ));
    if ($add) {
      drupal_add_js($videojs_js);
      drupal_add_css($videojs_css);
      drupal_add_js($lib_videojs_js);
      drupal_add_css($lib_videojs_css);
      if (!$added) {
        drupal_add_js($settings, array('type' => 'setting'));
        $added = TRUE;
      }
    }
    $return = array(
      'js' => array(
        array('data' => $videojs_js),
        array('data' => $videojs_js),
        array('data' => $settings, 'type' => 'setting'),
      ),
      'css' => array(
        array('data' => $videojs_css),
        array('data' => $videojs_css),
        array('data' => $directory . '/skins/hu.css'),
        array('data' => $directory . '/skins/tube.css'),
        array('data' => $directory . '/skins/vim.css'),
      ),
    );
  }

  return $return;
}
gagarine’s picture

Title: jScript Error: VideoJS is not defined » VideoJS.setupAllWhenReady need to be called after video.js library
Priority: Normal » Major

Some explanation... test with js aggregation off.

This script:

<script type="text/javascript" src="/sites/all/modules/videojs/theme/videojs.js?D"></script>

has to come *after* this one:

<script type="text/javascript" src="/sites/all/libraries/video-js/video.js?D"></script>
bradjones1’s picture

Status: Active » Needs review
StatusFileSize
new1.41 KB

Try this patch.

Jorrit’s picture

Status: Needs review » Fixed

Fixed in 7.x-1.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.