function videojs_get_version in Video.js (HTML5 Video Player) 8
Same name and namespace in other branches
- 6.2 videojs.module \videojs_get_version()
- 6 videojs.module \videojs_get_version()
- 7.3 videojs.module \videojs_get_version()
- 7 videojs.module \videojs_get_version()
- 7.2 videojs.module \videojs_get_version()
Return the version of Video.js installed.
Parameters
$path: The path to check for a Video.js installation. This can be a local path like sites/all/libraries/video-js or a remote path like http://mycdn.com/videojs. Do not add a trailing slash. Defaults to videojs_directory when using the local file path location or whatever location the Libraries API determines.
Return value
The version found or NULL if no version found.
1 call to videojs_get_version()
- videojs_requirements in ./
videojs.install - Implements hook_requirements().
File
- ./
videojs.module, line 38 - Exposes global functionality for video.js fields.
Code
function videojs_get_version($path = NULL) {
$version = NULL;
$config = \Drupal::config('videojs.settings');
if (!isset($path)) {
$path = $config
->get('videojs_directory');
}
// When admins specify a protocol-relative URL, add http because file_get_contents doesn't understand it.
if (strncmp('//', $path, 2) === 0) {
$path = 'http:' . $path;
}
// Don't use file_exists() because it doesn't work with URLs.
// Now admins can also refer to directories like http://mycdn.com/videojs.
$contents = @file_get_contents($path . '/video.js', FALSE, NULL, 0, 400);
if (!empty($contents)) {
$matches = array();
if (preg_match('/([\\d.]{3,})/i', $contents, $matches)) {
$version = $matches[1];
}
}
return $version;
}