You are here

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

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

Add the Video.js library to the page.

Parameters

$add: By default this function will add videojs to the page JavaScript array directly. If wanting to store the Video.js file as an #attached property, set this to FALSE and videojs_add() will only return the needed array suitable for use as an #attached property.

4 calls to videojs_add()
template_preprocess_videojs in includes/videojs.theme.inc
Preprocess function for videojs.tpl.php when using a playlist.
template_preprocess_videojs_view in includes/videojs.theme.inc
Preprocess function for videojs.tpl.php when displaying a view as a playlist.
videojs_field_formatter_view in ./videojs.module
Implements hook_field_formatter_view().
videojs_style_plugin::render in includes/videojs_style_plugin.inc
Render the display in this style.

File

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

Code

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')) {
    $filepath = $directory . '/video.js';
    $filepath_css = $directory . '/video-js.css';
  }
  if (isset($filepath)) {
    $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($filepath, array(
        'group' => JS_LIBRARY,
      ));
      drupal_add_css($filepath_css);
      drupal_add_js($videojs_js, array(
        'group' => JS_DEFAULT,
      ));
      drupal_add_css($videojs_css);
      if (!$added) {
        drupal_add_js($settings, array(
          'type' => 'setting',
        ));
        $added = TRUE;
      }
    }
    $return = array(
      'js' => array(
        $filepath => array(
          'group' => JS_LIBRARY,
        ),
        $videojs_js => array(
          'group' => JS_DEFAULT,
        ),
        array(
          'data' => $settings,
          'type' => 'setting',
        ),
      ),
      'css' => array(
        $filepath_css,
        $videojs_css,
        $directory . '/skins/hu.css',
        $directory . '/skins/tube.css',
        $directory . '/skins/vim.css',
      ),
    );
  }
  return $return;
}