You are here

function jplayer_get_version in jPlayer 7.2

Same name and namespace in other branches
  1. 6 jplayer.module \jplayer_get_version()

Return the version of jPlayer installed.

Parameters

string $file: File path of jPlayer file.

Return value

string|bool Version detected or FALSE.

2 calls to jplayer_get_version()
jplayer_library in ./jplayer.module
Implements hook_library().
jplayer_requirements in ./jplayer.install
Implements hook_requirements().

File

./jplayer.module, line 306
Provides an HTML5-compatible with Flash-fallback audio player.

Code

function jplayer_get_version($file = '') {
  if (!$file) {
    $file = _jplayer_get_js();
  }
  $style = 'full';
  if (preg_match('/min/', $file)) {
    $style = 'min';
  }
  $contents = file_get_contents($file);

  // No file data. Run away.
  if (!$contents) {
    return FALSE;
  }
  $matches = array();
  $preg = '/Version:?[ ]*([\\d.]+)/i';
  if ($style == 'min') {
    $preg = '/jPlayer ([\\d.]+) for jQuery/';
  }
  preg_match($preg, $contents, $matches);
  if (isset($matches[1])) {
    return $matches[1];
  }
  return FALSE;
}