5 * Exposes global functionality for video.js fields.
8 use Drupal\Core\Entity\EntityInterface;
9 use Drupal\Core\Routing\RouteMatchInterface;
10 use Drupal\file\Entity\File;
11 use Drupal\field\FieldStorageConfigInterface;
12 use Drupal\field\FieldConfigInterface;
15 * Implements hook_theme().
17 function videojs_theme() {
20 'variables' => array('items' => NULL, 'player_attributes' => NULL)
26 * Return the version of Video.js installed.
29 * The path to check for a Video.js installation. This can be a local path
30 * like sites/all/libraries/video-js or a remote path like
31 * http://mycdn.com/videojs. Do not add a trailing slash.
32 * Defaults to videojs_directory when using the local file path location
33 * or whatever location the Libraries API determines.
36 * The version found or NULL if no version found.
38 function videojs_get_version($path = NULL) {
40 $config = \Drupal::config('videojs.settings');
43 $path = $config->get('videojs_directory');
46 // When admins specify a protocol-relative URL, add http because file_get_contents doesn't understand it.
47 if (strncmp('//', $path, 2) === 0) {
48 $path = 'http:' . $path;
51 // Don't use file_exists() because it doesn't work with URLs.
52 // Now admins can also refer to directories like http://mycdn.com/videojs.
53 $contents = @file_get_contents($path . '/video.js', FALSE, NULL, 0, 400);
54 if (!empty($contents)) {
56 if (preg_match('/([\d.]{3,})/i', $contents, $matches)) {
57 $version = $matches[1];