X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fvideojs%2Fvideojs.module;fp=web%2Fmodules%2Fcontrib%2Fvideojs%2Fvideojs.module;h=49272367cb3cf0df27920a9eddb67b3bc11d1622;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hp=0000000000000000000000000000000000000000;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad;p=yaffs-website diff --git a/web/modules/contrib/videojs/videojs.module b/web/modules/contrib/videojs/videojs.module new file mode 100644 index 000000000..49272367c --- /dev/null +++ b/web/modules/contrib/videojs/videojs.module @@ -0,0 +1,61 @@ + array( + 'variables' => array('items' => NULL, 'player_attributes' => NULL) + ), + ); +} + +/** + * Return the version of Video.js installed. + * + * @param $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 + * The version found or NULL if no version found. + */ +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; +} \ No newline at end of file