You are here

function theme_video_flv in Video 7.2

Same name and namespace in other branches
  1. 6.5 video_formatter.inc \theme_video_flv()
  2. 6.4 video_formatter.inc \theme_video_flv()
  3. 7 video.theme.inc \theme_video_flv()

Theme wraper on Flash play on 3rd party

File

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

Code

function theme_video_flv($variables) {
  $item = $variables['item'];
  $video = NULL;
  foreach ($item['playablefiles'] as $file) {
    if ($file->filemime == 'video/mp4' || $file->filemime == 'video/flv' || $file->filemime == 'video/x-flv') {
      $video = $file;
      break;
    }
  }
  if ($video == NULL) {
    return '';
  }
  $extension = video_utility::getExtension($video->uri);
  $flash_player = variable_get('video_extension_' . $extension . '_flash_player', '');
  switch ($flash_player) {
    case 'flowplayer':

      // kjh: use a playlist to display the thumbnail if not auto playing
      if (!$variables['autoplay'] && !empty($item['thumbnailfile'])) {
        $options = array(
          'playlist' => array(
            $item['thumbnailfile']->url,
            array(
              'url' => file_create_url($video->uri),
              'autoPlay' => $variables['autoplay'],
              'autoBuffering' => $variables['autobuffering'],
            ),
          ),
        );
      }
      else {
        $options = array(
          'clip' => array(
            'url' => file_create_url($video->uri),
            'autoPlay' => $variables['autoplay'],
            'autoBuffering' => $variables['autobuffering'],
          ),
        );
      }
      $themed_output = theme('flowplayer', array(
        'config' => $options,
        'id' => 'flowplayer-' . $item['fid'],
        'attributes' => array(
          'style' => 'width:' . $variables['width'] . 'px;height:' . ($variables['height'] + 24) . 'px;',
        ),
      ));
      break;
    case 'jwplayer':
      $preset = variable_get('video_jwplayer_preset');
      $options = array(
        'width' => $variables['width'],
        'height' => $variables['height'],
        'autoplay' => $variables['autoplay'],
      );
      $config = array();
      if (!empty($item['thumbnailfile'])) {
        $config['image'] = $item['thumbnailfile']->url;
      }
      $themed_output = theme('jw_player', array(
        'file_object' => $video,
        'options' => $options,
        'config' => $config,
        'preset' => $preset,
        'sources' => json_decode(json_encode($item['playablefiles']), TRUE),
      ));
      break;
    default:
      $themed_output = t('No flash player has been set up.') . ' ' . l(t('Please select a player to play Flash videos.'), 'admin/config/media/video/players');
      break;
  }
  return theme('video_play_flv', array(
    'item' => $item,
    'themed_output' => $themed_output,
  ));
}