/** * 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: * - swftools_wijering4_swftools_preprocess_jwplayer4() * - swftools_flowplayer3_swftools_preprocess_flowplayer3() * * @see hook_swftools_playlist_PLAYER() */ 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']; }
<?php // See if playtime is available from id3 $duration = isset($element['getid3']['playtime_string']) ? $element['getid3']['playtime_string'] : ''; // Suppress notice errors when $element += array('author' => '', 'description' => '', 'image' => ''); // Output xml markup print "<title>" . check_plain($element['title']) . "</title>"; print "<creator>" . check_plain($element['author']) . "</creator>"; print "<location>" . check_url($element['fileurl']) . "</location>"; print "<annotation>" . check_plain($element['description']) . "</annotation>"; // Only add duration if it contains something (drupal.org/node/581470#comment-4147934 by David Stosik) if ($duration) { print "<duration>" . check_plain($duration) . "</duration>"; } // If there is an image then use it if ($element['image']) { // If imagecache is enabled see if we need to use a modified thumbnail if ($imagecache) { $element['image'] = swftools_imagecache_create_path($imagecache, $element['image']); } // Output the resulting image print "<image>" . check_plain($element['image']) . "</image>"; } // If this is a stream element then set meta if ($element['stream']) { print '<meta rel="streamer">' . check_plain($element['stream']) . '</meta>'; } ?> </track>
* the xml can be modified directly to provide customised xml handling for different players. * * By way of example this implementation of the template will include data from the ID3 tags * to pass the length of the clip, plus album and year data, if available. * * Available variables: * - $element: An array of available playlist data for this element. * * As a minimum the $element array can be expected to contain the following keys: * - fileurl * The resolved url to the file * - filepath * The filepath of the file (which will be different to the url if on the local file system) * - title * The title of the file, e.g. user supplied, assigned by ID3, or may be the filename * * Other keys may be available, depending on which additional modules have been enabled. * */ ?> <?php // If imagecache is enabled see if we need to use a modified thumbnail if ($imagecache) { $element['fileurl'] = swftools_imagecache_create_path($imagecache, $element['fileurl']); } // Output xml markup print '<photo imageurl="' . check_plain($element['fileurl']) . '" >'; print '<title>' . check_plain($element['title']) . '</title>'; print '<description>' . check_plain($element['description']) . '</description>'; print '</photo>';