You are here

function theme_video_formatter_player in Video 7.2

Default video cck formatter.

Makes sure the video being displayed exists, has been converted (if in queue). If not or the video is processed, then it will get the default player for the specific video type for output.

2 theme calls to theme_video_formatter_player()
video_field_formatter_view in ./video.field.inc
Implements hook_field_formatter_view().
video_file_embed in ./video.pages.inc
Menu callback : video/embed

File

./video.theme.inc, line 43
Theme related functions for the Video module.

Code

function theme_video_formatter_player(array $variables) {
  $item = $variables['item'];
  if (empty($item['fid'])) {
    return '';
  }

  // Only needs to be ran if they are converting videos
  if ($item['autoconversion'] && !$item['conversioncompleted']) {
    switch ($item['conversionstatus']) {
      case VIDEO_RENDERING_ACTIVE:
      case VIDEO_RENDERING_PENDING:
        return theme('video_inprogress');
      case VIDEO_RENDERING_FAILED:
        return theme('video_conversion_failed');
    }
  }

  // override player dimensions
  if (!empty($variables['player_dimensions'])) {
    $player_dimensions = explode('x', $variables['player_dimensions'], 2);
    $player_width = intval(trim($player_dimensions[0]));
    $player_height = intval(trim($player_dimensions[1]));
  }
  else {
    $player_width = 640;
    $player_height = 360;
  }

  // Poster image style
  if (!empty($item['thumbnailfile'])) {
    if (empty($variables['poster_image_style'])) {
      $item['thumbnailfile']->url = file_create_url($item['thumbnailfile']->uri);
    }
    else {
      $item['thumbnailfile']->url = image_style_url($variables['poster_image_style'], $item['thumbnailfile']->uri);
    }
  }

  // Determine theme function based on the playable files.
  // If one of the video types is configured to use an HTML5 player then the
  // HTML5 theme function is used.
  // If the last or only video type is configured to use an FLV player then the
  // FLV theme function is used.
  // In all other cases the player configured for the last or only video type
  // is used.
  $defaults = video_utility::getVideoExtensionPlayers();
  foreach ($item['playablefiles'] as $playablefile) {
    $extension = video_utility::getExtension($playablefile->uri);
    $theme_function = variable_get('video_extension_' . $extension, $defaults[$extension]);
    if ($theme_function == 'video_play_html5') {
      $theme_function = 'video_html5';
      break;
    }
    elseif ($theme_function == 'video_play_flv') {
      $theme_function = 'video_flv';
    }
  }
  return theme($theme_function, array(
    'item' => $item,
    'width' => $player_width,
    'height' => $player_height,
    'entity' => $variables['entity'],
    'entity_type' => $variables['entity_type'],
  ));
}