You are here

function theme_video in Video 7

File

./video.theme.inc, line 39

Code

function theme_video($variables) {
  $themed_output = '';
  if (empty($variables['item']['fid'])) {
    return '';
  }
  $field_settings = $variables['field']['settings'];
  $instance_settings = $variables['instance']['settings'];

  // Only needs to be ran if they are converting videos
  if (isset($field_settings['autoconversion']) && $field_settings['autoconversion']) {
    module_load_include('inc', 'video', '/includes/conversion');
    $conversion = new video_conversion();
    if ($video = $conversion
      ->load_job($variables['item']['fid'])) {
      if ($video->video_status == VIDEO_RENDERING_ACTIVE || $video->video_status == VIDEO_RENDERING_PENDING) {
        return theme('video_inprogress');
      }
      else {
        if ($video->video_status == VIDEO_RENDERING_FAILED) {
          return theme('video_conversion_failed');
        }
      }
    }
  }

  // Setup our video object
  module_load_include('inc', 'video', '/includes/video_helper');
  $video_helper = new video_helper();
  $video = $video_helper
    ->video_object($variables);

  // Lets spit out our theme based on the extension
  $defaults = video_video_extensions();
  $theme_function = variable_get('video_extension_' . $video->player, $defaults[$video->player]);

  // Lets do some special handling for our flv files, HTML5 to accomdate multiple players.
  switch ($theme_function) {
    case 'video_play_flv':
      return theme('video_flv', array(
        'video' => $video,
        'themed_output' => $themed_output,
      ));
      break;
    case 'video_play_html5':
      return theme('video_html5', array(
        'video' => $video,
        'themed_output' => $themed_output,
      ));
      break;
    default:
      return theme($theme_function, array(
        'video' => $video,
        'themed_output' => $themed_output,
      ));
      break;
  }
}