You are here

function swftools_jw5_swftools_preprocess_jwplayer5 in SWF Tools 6.3

Implementation of hook_swftools_preprocess_[player]().

File

jw5/swftools_jw5.module, line 420
Enables SWF Tools support for LongTail Player 5.

Code

function swftools_jw5_swftools_preprocess_jwplayer5(&$data) {

  // Get current defaults for the player
  $saved_settings = _swftools_jw5_flashvars($data['othervars']['profile']);

  // Prepare an array of flashvars by merging defaults and user values
  $data['flashvars'] = array_merge($saved_settings, $data['flashvars']);

  // If a skin has been set it may need to be expanded to a path if not already a full url
  if (isset($data['flashvars']['skin'])) {
    if (!valid_url($data['flashvars']['skin'], TRUE)) {
      $data['flashvars']['skin'] = base_path() . swftools_get_library('mediaplayer-5') . '/skins/' . $data['flashvars']['skin'];
    }
  }

  // If an image has been set then use it
  if ($data['othervars']['image']) {

    // Get source path to the image file
    $source = swftools_get_url_and_path($data['othervars']['image']);

    // If $source succeeded add image to the playlist
    if ($source) {

      // See if we need to apply an imagecache preset
      if ($saved_settings['imagecache_player'] != SWFTOOLS_UNDEFINED) {
        $source['fileurl'] = swftools_imagecache_create_path($saved_settings['imagecache_player'], $source['fileurl']);
      }

      // Store result in flashvars
      $data['flashvars']['image'] = $source['fileurl'];
    }
  }

  // Don't output imagecache_variables
  unset($data['flashvars']['imagecache_player'], $data['flashvars']['imagecache_playlist']);

  // Is this a single streamed file, or an entirely stream playlist?
  if ($data['othervars']['stream'] && $data['othervars']['stream'] !== TRUE) {

    // Set the streamer flashvar
    $data['flashvars']['streamer'] = $data['othervars']['stream'];
  }

  // Add the accessible controls?
  if ($data['flashvars']['accessible']) {

    // Add accessible controls
    $data['othervars']['#suffix'] = theme('swftools_jw5_accessible', $data['othervars']['id'], $data['flashvars']['accessible']);
  }

  // Unset the accessible parameters from flashvars so they are not output
  unset($data['flashvars']['accessible']);

  // Attach file url of the content to display to flashvars
  $data['flashvars']['file'] = $data['othervars']['file_url'];

  // Add JavaScript to enable auto-close behavior and accessibility
  swftools_jw5_add_js();
}