'swftools_wijering4', 'title' => t('JW Player 4'), 'download' => 'http://developer.longtailvideo.com/trac/browser/tags', 'width' => 400, 'height' => 300, 'library' => $library . $player, 'profile' => array( 'path' => 'wijering4', 'settings' => array('swftools_jwplayer4'), 'file' => 'swftools_wijering4.admin.inc', 'page argument' => 'swftools_wijering4_profile_form', ), ); // Wijering support various actions with the same player and info. $methods['video']['jwplayer4'] = $jwplayer; $methods['video_list']['jwplayer4'] = $jwplayer; $methods['audio']['jwplayer4'] = $jwplayer; $methods['audio_list']['jwplayer4'] = $jwplayer; $methods['swftools_media_display']['jwplayer4'] = $jwplayer; $methods['media_list']['jwplayer4'] = $jwplayer; $methods['image_list']['jwplayer4'] = $jwplayer; // Return methods return $methods; } /** * Implementation of hook_menu(). */ function swftools_wijering4_menu() { $items['admin/settings/swftools/wijering4'] = array( 'title' => 'JW Player 4', 'description' => 'Settings for '. l('JW Player 4', 'http://developer.longtailvideo.com/trac/browser/tags') . '.', 'access arguments' => array('administer flash'), 'page callback' => 'drupal_get_form', 'page arguments' => array('swftools_wijering4_admin_form'), 'file' => 'swftools_wijering4.admin.inc', ); $items['admin/settings/swftools/wijering4/autocomplete'] = array( 'title' => 'Autocomplete skin name', 'access arguments' => array('administer flash'), 'page callback' => 'swftools_wijering4_autocomplete_skin', 'type' => MENU_CALLBACK, 'file' => 'swftools_wijering4.admin.inc', ); return $items; } /** * Returns an array of default settings for the JW Player * * Return either the full set, or the minimum set, of player settings. The full set is * normally request by the administration page in order to populate the form, while the * minimum set returns just those settings needed to successfully render a player. * * @param string $profile * (optional) Name of profile to use. * @param int $mode * (optional) Use one of the following constants: * - SWFTOOLS_MINIMUM_SETTINGS: Return the minimum settings to render a player. * - SWFTOOLS_FULL_SETTINGS: Return the full complement of settings. * * @return array * An array of settings. */ function _swftools_wijering4_settings($profile = '', $mode = SWFTOOLS_MINIMUM_SETTINGS) { // Define the defaults for the minimum and full conditions $defaults = array( SWFTOOLS_MINIMUM_SETTINGS => array( 'basic' => array( 'width' => '400', 'height' => '320', ), 'appearance' => array( 'fillemptyimages' => 0, ), 'accessibility' => array( 'accessible' => 0, ), 'imagecache' => array( 'imagecache' => SWFTOOLS_UNDEFINED, ), ), SWFTOOLS_FULL_SETTINGS => array( 'basic' => array( 'playlistsize' => '', 'width' => '400', 'height' => '320', ), 'color' => array( 'backcolor' => '', 'frontcolor' => '', 'lightcolor' => '', 'screencolor' => '', ), 'appearance' => array( 'skin' => '', 'logo' => '', 'overstretch' => 'default', 'controlbar' => 'default', 'playlist' => 'default', 'plugins' => '', 'fillemptyimages' => 0, ), 'playback' => array( 'autostart' => 'default', 'bufferlength' => '', 'displayclick' => 'default', 'repeat' => 'default', 'shuffle' => 'default', 'volume' => '', ), 'interaction' => array( 'captions' => '', 'link' => '', 'linktarget' => 'default', 'streamscript' => '', 'type' => 'default', 'fullscreen' => 'default', ), 'accessibility' => array( 'accessible' => SWFTOOLS_ACCESSIBLE_DISABLED, ), 'imagecache' => array( 'imagecache_player' => SWFTOOLS_UNDEFINED, 'imagecache_playlist' => SWFTOOLS_UNDEFINED, ), ), ); // TODO: Does this actually work? Once a form has been stored will swftools_variable_get() not // always retrieve a full set of variables? The minimum set will only be returned when there // are no settings stored in the database? // Retrieve current default settings $settings = swftools_variable_get('swftools_jwplayer4', $defaults[SWFTOOLS_MINIMUM_SETTINGS], $profile); // If a full set of settings are requested for the admin page then merge with full defaults if ($mode == SWFTOOLS_FULL_SETTINGS) { $settings = swftools_array_merge($defaults[SWFTOOLS_FULL_SETTINGS], $settings); } // Return resulting defaults return $settings; } /** * Return the default flashvar configuration for JW Player 4. * * This function is called from swftools_wijering4_swftools_flashvars() which is called from swf() * It will return the default flashvar configuration, just prior to any overrides * passed into swf(). We start with the settings defined on admin/swf/wijering * which are returned by _swftools_wijering4_settings(). Then we prepare these values for output * to html (eg. '1' become 'true') and we unset undefined flashvars to prevent their output. * * TODO: Could we just do this when we save the settings, and then save the result, as this doesn't * change until the settings are updated. * * @param string $profile * (optional) Name of profile to use. * * @return array * An array of flashvars as key => value pairs. */ function _swftools_wijering4_flashvars($profile = '') { // Initialise cache to handle repeated calls static $cache = array(); // Store name of profile $_profile = $profile ? $profile : SWFTOOLS_UNDEFINED; // If no settings stored for this profile then fetch them if (!isset($cache[$_profile])) { // Get saved settings for this method. $settings = _swftools_wijering4_settings($profile); // Flatten defaults swftools_array_flatten($settings); // Iterate over boolean settings foreach (array('autostart', 'shuffle', 'fullscreen') as $key) { // Settings are already encoded properly on the settings page, but if we called from PHP it might be 1/0 or TRUE/FALSE if (isset($settings[$key])) { $settings[$key] = _swftools_tf($settings[$key]); } } // Store the result $cache[$_profile] = $settings; } // Return the result return $cache[$_profile]; } /** * Implementation of hook_swftools_playlist_[player](). */ function swftools_wijering4_swftools_playlist_jwplayer4($data) { // Get current defaults for the player $saved_settings = _swftools_wijering4_flashvars($data['othervars']['profile']); // Initialise a string to contain the elements $xml = ''; // Iterate over the playlist to build elements xml foreach ($data['othervars']['playlist_data']['playlist'] AS $track => $details) { if (!$details['image'] && $saved_settings['fillemptyimages']) { $details['image'] = theme('swftools_empty_image', $data); } // Create an individual xml element $xml .= theme('swftools_wijering4_playlist_element', $details, $saved_settings['imagecache_playlist'] == SWFTOOLS_UNDEFINED ? '' : $saved_settings['imagecache_playlist']); } // Add xml wrapper around the elements $xml = theme('swftools_wijering4_playlist_wrapper', $data['othervars']['playlist_data']['header'], $xml); // Return the resulting xml return $xml; } /** * Implementation of hook_swftools_variable_mapping(). * */ function swftools_wijering4_swftools_variable_mapping() { return array( 'jwplayer4' => array( 'height' => 'flashvars', 'width' => 'flashvars', 'shuffle' => 'flashvars', 'fullscreen' => 'flashvars', 'autostart' => 'flashvars', 'quality' => 'flashvars', 'backcolor' => 'flashvars', 'frontcolor' => 'flashvars', 'lightcolor' => 'flashvars', 'screencolor' => 'flashvars', 'logo' => 'flashvars', 'captions' => 'flashvars', 'link' => 'flashvars', 'streamscript' => 'flashvars', 'skin' => 'flashvars', 'playlistsize' => 'flashvars', 'bufferlength' => 'flashvars', 'volume' => 'flashvars', 'type' => 'flashvars', 'repeat' => 'flashvars', 'linktarget' => 'flashvars', 'stretching' => 'flashvars', 'playlist' => 'flashvars', 'controlbar' => 'flashvars', 'displayclick' => 'flashvars', ), ); } /** * Implementation of hook_help(). */ function swftools_wijering4_help($path, $arg) { switch ($path) { case 'admin/settings/swftools/wijering4': return '

' . t('These are the settings for Jeroen Wijering\'s FLV Media Player 4. For details of what each parameter does refer to the JW Player for Flash wiki page. It is possible that you do not need to change any of these settings and blank values will defer to friendly defaults. Note that the label in (brackets) is the actual flashvar name and corresponds to the wiki page. If content is embedded using the SWF Tools filter then each parameter can be over-ridden by specifying a new value in the filter string.', array('@wijering' => 'http://code.jeroenwijering.com/trac/wiki/FlashVars')) . '

'; } } /** * Implementation of hook_theme(). */ function swftools_wijering4_theme() { return array( 'swftools_wijering4_playlist_element' => array( 'template' => 'swftools-wijering4-playlist-element', 'arguments' => array('element' => NULL, 'imagecache' => NULL), ), 'swftools_wijering4_playlist_wrapper' => array( 'template' => 'swftools-wijering4-playlist-wrapper', 'arguments' => array('header' => NULL, 'xml' => NULL), ), 'swftools_wijering4_accessible' => array( 'arguments' => array('id' => NULL, 'visible' => NULL), ), ); } /** * Returns markup to enable accessible controls for the Wijering 4 player. * * @param string $id * id of the player to be made accessible. * @param int $visible * Whether the controls should be visible. Options are one the following constants: * - SWFTOOLS_ACCESSIBLE_DISABLED * - SWFTOOLS_ACCESSIBLE_HIDDEN * - SWFTOOLS_ACCESSIBLE_VISIBLE * * @return string * Mark up to place accessible controls on the page. * * @ingroup themeable * @ingroup swftools */ function theme_swftools_wijering4_accessible($id, $visible) { $actions = array( 'play' => t('Play'), 'pause' => t('Pause'), 'mute' => t('Mute'), 'unmute' => t('Unmute'), 'stop' => t('Rewind and stop'), ); return theme('swftools_accessible_controls', 'wijering4', $id, $actions, $visible); } /** * Implementation of hook_init(). */ function swftools_wijering4_init() { // Add JavaScript to enable auto-close behavior and accessibility if (variable_get('swftools_always_add_js', SWFTOOLS_ALWAYS_ADD_JS)) { swftools_wijering4_add_js(); } } /** * Adds Wijering4 JavaScript to the page. */ function swftools_wijering4_add_js() { // Add JavaScript to enable auto-close behavior and accessibility drupal_add_js(drupal_get_path('module', 'swftools_wijering4') . '/swftools_wijering4.js'); } /** * Implementation of hook_swftools_preprocess_[player](). */ function swftools_wijering4_swftools_preprocess_jwplayer4(&$data) { // Get current defaults for the player $saved_settings = _swftools_wijering4_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('mediaplayer4') . '/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_wijering4_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_wijering4_add_js(); }