You are here

function theme_video_cck_youtube_flash in Embedded Media Field 5

The embedded flash displaying the youtube video.

2 theme calls to theme_video_cck_youtube_flash()
video_cck_youtube_preview in contrib/video_cck/providers/youtube.inc
hook video_cck_PROVIDER_video this actually displays the preview-sized video we want, commonly for the teaser
video_cck_youtube_video in contrib/video_cck/providers/youtube.inc
hook video_cck_PROVIDER_video this actually displays the full/normal-sized video we want, usually on the default page view

File

contrib/video_cck/providers/youtube.inc, line 262

Code

function theme_video_cck_youtube_flash($embed, $width, $height, $autoplay, $options = array()) {
  static $count;
  if ($embed) {
    $fullscreen = isset($options['fullscreen']) ? $options['fullscreen'] : variable_get('emvideo_youtube_full_screen', 1);
    $fullscreen_value = $fullscreen ? "true" : "false";
    $fs = $fullscreen ? "&fs={$fullscreen}" : "";
    $related = isset($options['related']) ? $options['related'] : variable_get('video_cck_youtube_show_related_videos', 0);
    $related = "rel={$related}";
    $autoplay = isset($options['autoplay']) ? $options['autoplay'] : $autoplay;
    $autoplay_value = $autoplay ? '&autoplay=1' : '';
    $show_colors = isset($options['show_colors']) ? $options['show_colors'] : variable_get('video_cck_youtube_show_colors', FALSE);
    if ($show_colors) {
      $color1 = isset($options['color1']) ? $options['color1'] : variable_get('video_cck_youtube_colors_color1', VIDEO_CCK_YOUTUBE_COLOR1_DEFAULT);
      $color2 = isset($options['color2']) ? $options['color2'] : variable_get('video_cck_youtube_colors_color2', VIDEO_CCK_YOUTUBE_COLOR2_DEFAULT);
      $colors = '&color1=0x' . video_cck_youtube_convert_color($color1) . '&color2=0x' . video_cck_youtube_convert_color($color2);
    }
    $border = isset($options['border']) ? $options['border'] : variable_get('video_cck_youtube_show_border', FALSE);
    $border = $border ? '&border=1' : '';
    $enablejsapi = isset($options['enablejsapi']) ? $options['enablejsapi'] : variable_get('video_cck_youtube_enablejsapi', TRUE);
    $enablejsapi = $enablejsapi ? '&enablejsapi=1&playerapiid=ytplayer' : '';
    $allowScriptAcess = $enablejsapi ? 'always' : 'sameDomain';
    $id = isset($options['id']) ? $options['id'] : 'video-cck-youtube-flash-' . ++$count;
    $div_id = isset($options['div_id']) ? $options['div_id'] : 'video_cck_youtube_flash_wrapper_' . $count;
    $high_quality = isset($options['high_quality']) ? $options['high_quality'] : variable_get('emvideo_youtube_high_quality', FALSE);
    $high_quality = $high_quality ? '&ap=%2526fmt%3D18' : '';
    $url = "http://www.youtube.com/v/{$embed}&{$related}{$autoplay_value}{$colors}{$border}{$high_quality}{$enablejsap}{$fs}";
    if (variable_get('emfield_swfobject', FALSE) && (module_exists('swfobject_api') || variable_get('emfield_swfobject_location', ''))) {
      if (module_exists('swfobject_api')) {
        $params['width'] = $width;
        $params['height'] = $height;
        $params['div_id'] = $div_id;
        $output .= theme('swfobject_api', $url, $params, $vars, $div_id);
      }
      else {
        drupal_add_js(variable_get('emfield_swfobject_location', ''));
        $output .= <<<FLASH
          <div id="{<span class="php-variable">$div_id</span>}">
            Sorry, you need to install flash to see this content.
          </div>
          <script language="JavaScript" type="text/javascript">
            var so = new SWFObject("{<span class="php-variable">$url</span>}", "{<span class="php-variable">$div_id</span>}", "{<span class="php-variable">$width</span>}", "{<span class="php-variable">$height</span>}", "7");
            so.write("{<span class="php-variable">$div_id</span>}");
          </script>
FLASH;
      }
    }
    else {
      $output .= <<<FLASH
        <div id="{<span class="php-variable">$div_id</span>}"><object type="application/x-shockwave-flash" height="{<span class="php-variable">$height</span>}" width="{<span class="php-variable">$width</span>}" data="{<span class="php-variable">$url</span>}" id="{<span class="php-variable">$id</span>}">
          <param name="movie" value="{<span class="php-variable">$url</span>}" />
          <param name="allowScriptAcess" value="sameDomain"/>
          <param name="quality" value="best"/>
          <param name="bgcolor" value="#FFFFFF"/>
          <param name="scale" value="noScale"/>
          <param name="salign" value="TL"/>
          <param name="FlashVars" value="playerMode=embedded" />
          <param name="wmode" value="transparent" />
        </object></div>
FLASH;
    }
  }
  return $output;
}