You are here

function hook_swftools_preprocess_PLAYER in SWF Tools 6.3

Does the final preparation prior to rendering the specified player.

This hook is called just before the player is output on to the page. At this point the SWF Tools data array is complete and the element is almost ready for display. Prior to this hook being called SWF Tools has been working out what action is needed, and what player and embedding method is going to be used. It is up to the implementing module to do the final preparations and configuration of the Flash element. For example, it the player requires a specific flashvar to be set in order to find the playlist then this should be done in this hook.

A common flow of logic in this hook is to determine whether a splash image is being used, and if so assign it to a flashvar, followed by assignment of the generated xml playlist to another flashvar.

More complex code is possible, and sometimes necessary. For example, the FlowPlayer 3 module uses JSON notation to create a single flashvar that holds the entire configuration. In that case the hook function is more complex since it must assemble the JSON array from the constituent data in the $data array.

This function does not return anything - $data should be passed by reference and then modified directly.

If any supporting JavaScript is required then it can be added via this hook. Some care is needed when using JavaScript dependent players to make sure that the JavaScript is always available on the finished page. In particular, if the site allows content to be added via the input filter then this hook is only called the first time the content is generated. The resulting markup is cached by the input filter and on subsequent views the cached version will be used. The module must therefore make sure it adds JavaScript to every page by using hook_init().

For examples of hook_swftools_preprocess_PLAYER() see:

See also

hook_swftools_playlist_PLAYER()

Related topics

13 functions implement hook_swftools_preprocess_PLAYER()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

swftools_flexpaper_swftools_preprocess_flexpaper in flexpaper/swftools_flexpaper.module
Implementation of hook_swftools_preprocess_[player]().
swftools_flowplayer3_swftools_preprocess_flowplayer3 in flowplayer3/swftools_flowplayer3.module
Implementation of hook_swftools_preprocess_[player]().
swftools_flowplayer_swftools_preprocess_flowplayer in flowplayer/swftools_flowplayer.module
Implementation of hook_swftools_preprocess_[player]().
swftools_imagerotator_swftools_preprocess_imagerotator in imagerotator/swftools_imagerotator.module
Implementation of hook_swftools_preprocess_[player]().
swftools_jw5_swftools_preprocess_jwplayer5 in jw5/swftools_jw5.module
Implementation of hook_swftools_preprocess_[player]().

... See full list

File

docs/swftools.php, line 226
Doxygen documentation for SWF Tools.

Code

function hook_swftools_preprocess_PLAYER(&$data) {

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

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

  // 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 a flashvar called image
      $data['flashvars']['image'] = $source['fileurl'];
    }
  }

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

  // Attach the generated path the xml based playlist
  $data['flashvars']['file'] = $data['othervars']['file_url'];
}