You are here

function videojs_add in Video.js (HTML5 Video Player) 7.3

Same name and namespace in other branches
  1. 6.2 videojs.module \videojs_add()
  2. 6 videojs.module \videojs_add()
  3. 7 videojs.module \videojs_add()
  4. 7.2 videojs.module \videojs_add()

Add the Video.js library to the page.

2 calls to videojs_add()
videojs_field_formatter_view in ./videojs.module
Implements hook_field_formatter_view().
videojs_preprocess_videojs in includes/videojs.theme.inc
Preprocess function for videojs.tpl.php.

File

./videojs.module, line 377
Provides an HTML5-compatible with Flash-fallback video player.

Code

function videojs_add($add = TRUE) {
  $added =& drupal_static(__FUNCTION__);
  $path = videojs_get_path();
  $remote = strpos($path, '://') !== FALSE || strncmp('//', $path, 2) === 0;
  $jsdata = $path . '/video.js';
  $jsopts = array(
    'group' => JS_LIBRARY,
    'preprocess' => !$remote,
    'type' => $remote ? 'external' : 'file',
    'weight' => 1,
  );
  $cssdata = $path . '/video-js.css';
  $cssopts = array(
    'preprocess' => !$remote,
    'type' => $remote ? 'external' : 'file',
  );
  $swfdata = 'videojs.options.flash.swf = "' . file_create_url($path . '/video-js.swf') . '"';
  $swfopts = array(
    'group' => JS_LIBRARY,
    'type' => 'inline',
    'weight' => 5,
  );
  if ($add && !$added) {
    drupal_add_js($jsdata, $jsopts);
    drupal_add_css($cssdata, $cssopts);
    drupal_add_js($swfdata, $swfopts);
    $added = TRUE;
  }
  return array(
    'js' => array(
      $jsdata => $jsopts,
      $swfdata => $swfopts,
    ),
    'css' => array(
      $cssdata => $cssopts,
    ),
  );
}