You are here

function theme_emvideo_zzz_custom_url_embedded_video in Embedded Media Field 6.3

Same name and namespace in other branches
  1. 6 contrib/emvideo/providers/zzz_custom_url.inc \theme_emvideo_zzz_custom_url_embedded_video()
2 theme calls to theme_emvideo_zzz_custom_url_embedded_video()
emvideo_zzz_custom_url_preview in contrib/emvideo/providers/zzz_custom_url.inc
emvideo_zzz_custom_url_video in contrib/emvideo/providers/zzz_custom_url.inc

File

contrib/emvideo/providers/zzz_custom_url.inc, line 117
This is an include file used by emfield.module.

Code

function theme_emvideo_zzz_custom_url_embedded_video($type, $url, $width, $height, $autoplay = FALSE, $field = NULL, $item = NULL, $options = array()) {
  if (count($parts = explode('rtmp://', $url)) == 2) {
    if (module_exists('flowplayer')) {
      $config = array(
        'clip' => array(
          'autoPlay' => $autoplay,
          'url' => basename($url),
          'provider' => 'rtmp',
        ),
        'plugins' => array(
          'rtmp' => array(
            'url' => url(drupal_get_path('module', 'flowplayer') . '/flowplayer/flowplayer.rtmp.swf', array(
              'absolute' => TRUE,
            )),
            'netConnectionUrl' => dirname($url),
          ),
        ),
      );
      $attributes = array(
        'style' => "width:{$width}px;height:{$height}px;",
      );

      // Build the Thumbnail image for the player.
      $tn_options = array(
        'width' => $width,
        'height' => $height,
      );
      $thumbnail = '<span></span>' . theme('emvideo_video_thumbnail', NULL, $item, 'emvideo_thumbnail', $options['node'], TRUE, $tn_options);
      drupal_add_css(drupal_get_path('module', 'emvideo') . '/emvideo.custom-url.css');
      return theme('flowplayer', $config, 'emvideo-zzz-custom-url-embedded-video', $attributes, $thumbnail);
    }
  }
  else {
    if ($url = url($url, array(
      'external' => TRUE,
      'absolute' => TRUE,
    ))) {
      global $base_path;
      $url = $base_path . $url;
      if (module_exists('flowplayer')) {
        $config = array(
          'clip' => array(
            'autoPlay' => $autoplay,
            'url' => $url,
          ),
        );
        $attributes = array(
          'style' => "width:{$width}px;height:{$height}px;",
        );

        // Build the Thumbnail image for the player.
        $tn_options = array(
          'width' => $width,
          'height' => $height,
        );
        $thumbnail = '<span></span>' . theme('emvideo_video_thumbnail', NULL, $item, 'emvideo_thumbnail', $options['node'], TRUE, $tn_options);
        drupal_add_css(drupal_get_path('module', 'emvideo') . '/emvideo.custom-url.css');
        return theme('flowplayer', $config, 'emvideo-zzz-custom-url-embedded-video', $attributes, $thumbnail);
      }

      // Find the path to the JW FLV Media Player.
      $path = emfield_flvmediaplayer_url();

      // If the JW FLV Player has been installed, the yt.swf file is in the same
      // folder, and the server has been configured to use it for YouTube videos,
      // then we'll do so now.
      $use_flv = isset($options['use_flv']) ? $options['use_flv'] : variable_get('emvideo_zzz_custom_url_use_jw_flv', TRUE);

      // Set up the FLV Media Player options, assuming we're supposed to,
      // and the player is actually installed on the system.
      if ($use_flv && ($flv_path = emfield_flvmediaplayer_url())) {
        global $base_path;

        // Build the Thumbnail image for the player.
        $tn_options = array(
          'width' => $width,
          'height' => $height,
          'return_url' => TRUE,
        );
        $flashvars = array();

        // Grab the thumbnail for this video and tell JW FLV Player about it.
        $flashvars['image'] = theme('emvideo_video_thumbnail', NULL, $item, 'emvideo_thumbnail', $options['node'], FALSE, $tn_options);

        // We need to set the file to the original video.
        $flashvars['file'] = $url;

        // The JW FLV Player uses its own autoplay flashvar.
        $flashvars['autostart'] = $autoplay ? 'true' : 'false';

        // The URL will now be the JW FLV Player.
        $url = $base_path . $flv_path;
      }
      else {

        // We don't have access to FLV Media Player, so reset the option.
        $use_flv = FALSE;
      }
      if ($use_flv && module_exists('flvmediaplayer')) {

        // If we are using the JW FLV Player, defer to the flvmediaplayer module
        // for display.
        $params['width'] = $width;
        $params['height'] = $height;
        $params['div_id'] = $id;
        $params['allowFullScreen'] = $fullscreen_value;

        // If we have been told to use a specific FLV Player Option from
        // that module, then use it here.
        $flv_profile = isset($options['flv_profile']) ? $options['flv_profile'] : variable_get('emfield_flv_profile', '');
        if ($flv_profile) {

          // Get the configuration data for this profile.
          $data = flvmediaplayer_build_player_data($options['node'], $flv_profile, array(
            'file' => $flashvars['file'],
          ));
          $data['params']['width'] = $width;
          $data['params']['height'] = $height;
          $data['flashvars']['autostart'] = $flashvars['autostart'];
          $data['params']['allowFullScreen'] = $fullscreen_value;
          $data['flashvars']['image'] = $flashvars['image'];
          $output = theme('flvmediaplayer_render_player', $url, $data['params'], $data['flashvars']);
        }
        else {

          // Just display the default jw flv media player.
          $output = theme('flvmediaplayer_render_player', $url, $params, $flashvars);
        }
      }
      else {
        if (variable_get('emfield_swfobject', FALSE) && (module_exists('swfobject_api') || variable_get('emfield_swfobject_location', ''))) {

          // Use SWFObject API module if it's installed.
          // Note that we're going to try to send the Flv Media player as well,
          // assuming it's been set up and the flvmediaplayer module has not.
          $params['width'] = $width;
          $params['height'] = $height;
          $params['div_id'] = $id;
          $params['allowFullScreen'] = $fullscreen_value;
          $output = theme('emfield_swfobject', $url, $params, $flashvars, $id);
        }
        else {
          if ($use_flv) {
            $flashvars = drupal_query_string_encode($flashvars);
            $output = <<<FLV
        <div id="{<span class="php-variable">$div_id</span>}"><embed src="{<span class="php-variable">$url</span>}" width="{<span class="php-variable">$width</span>}" height="{<span class="php-variable">$height</span>}" allowscriptaccess="always" allowfullscreen="{<span class="php-variable">$fullscreen_value</span>}" flashvars="{<span class="php-variable">$flashvars</span>}" /></div>
FLV;
          }
          else {
            switch ($type) {
              case 'wmv':
              case 'wma':
                $autostart = $autoplay ? '1' : '0';
                $output = '<embed src="' . $url . '" width="' . $width . '" height="' . $height . '" autostart="' . $autostart . '" showcontrols="1" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/windowsmedia/download/"> </embed>';
                break;
              case 'mov':
              case 'mp4':
              case 'm4v':
                $autostart = $autoplay ? 'true' : 'false';
                $output = '<embed src="' . $url . '" width="' . $width . '" height="' . $height . '" autoplay="' . $autostart . '" controller="true" type="video/quicktime" scale="tofit" pluginspage="http://www.apple.com/quicktime/download/"> </embed>';
                break;
              case 'rm':
                $autostart = $autoplay ? 'true' : 'false';
                $output = '<embed type="audio/x-pn-realaudio-plugin" src="' . $url . '" width="' . $width . '" height="' . $height . '" autostart="' . $autostart . '" controls="imagewindow" nojava="true" console="c1183760810807" pluginspage="http://www.real.com/"></embed><br /><embed type="audio/x-pn-realaudio-plugin" src="' . $url . '" width="' . $width . '" height="26" autostart="' . $autostart . '" nojava="true" controls="ControlPanel" console="c1183760810807"> </embed>';
                break;
              case 'swf':
                $output = '<embed src="' . $url . '" width="' . $width . '" height="' . $height . '" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
                break;
              case 'flv':
                $autostart = $autoplay ? 'true' : 'false';
                $output = '<embed src="http://freevideocoding.com/flvplayer.swf?file=' . $url . '&amp;autoStart=' . $autostart . '" width="' . $width . '" height="' . $height . '" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>';
                break;
            }
          }
        }
      }
      return $output;
    }
  }
}