You are here

function jw_player_supports in JW Player 7.2

Checks a file for JW Player supported media formats.

See http://www.longtailvideo.com/support/jw-player/28836/media-format-support for the list of supported media formats.

Parameters

array|object $file: A file object (or array) to check for support.

Return value

bool TRUE if the file is supported by JW Player.

1 string reference to 'jw_player_supports'
jw_player_field_formatter_view in ./jw_player.module
Implements hook_field_formatter_view().

File

./jw_player.module, line 1026
Adds a theme function which allows theme developers to use the JW Player.

Code

function jw_player_supports($file) {
  $file = (object) $file;
  if (in_array($file->filemime, jw_player_supported_mimetypes())) {

    //Loads on-behalf implementations from checks/ directory.
    $path = drupal_get_path('module', 'jw_player') . '/checks';
    $files = drupal_system_listing('/.*\\.inc$/', $path, 'name', 0);
    foreach ($files as $check_file) {
      if (strstr($check_file->uri, '/checks/') && module_exists($check_file->name)) {
        require_once DRUPAL_ROOT . '/' . $check_file->uri;
      }
    }
    if ($check_modules = module_implements('jw_player_supports')) {

      // Return TRUE as soon as an implementation of hook_jw_player_supports()
      // returns TRUE.
      foreach ($check_modules as $module) {
        if (module_invoke($module, 'jw_player_supports', $file)) {
          return TRUE;
        }
      }

      // Return FALSE if no implementation of hook_jw_player_supports() returned
      // TRUE.
      return FALSE;
    }
    else {

      // Return TRUE if no module implements hook_jw_player_supports().
      return TRUE;
    }
  }
  else {
    return FALSE;
  }
}