WIJERING_MEDIAPLAYER, 'module' => 'wijering', 'file' => 'file', // Define which flashvar to assign a 'file to play' variable. 'version' => '7', 'shared_file' => 'flash_media_player/mediaplayer.swf', 'title' => t('Flash Media Player - Jeroen Wijering'), ); // Wijering support various actions with the same player and info. $methods[SWFTOOLS_FLV_DISPLAY][WIJERING_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_FLV_DISPLAY_LIST][WIJERING_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MP3_DISPLAY][WIJERING_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MP3_DISPLAY_LIST][WIJERING_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MEDIA_DISPLAY][WIJERING_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MEDIA_DISPLAY_LIST][WIJERING_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_IMAGE_DISPLAY_LIST][WIJERING_MEDIAPLAYER] = $media_player; // And with rotator $image_rotator = array( 'name' => WIJERING_IMAGEROTATOR, 'module' => 'wijering', 'file' => 'file', // Define which flashvar to assign a 'file to play' variable. 'version' => '7', 'shared_file' => 'flash_image_rotator/imagerotator.swf', 'title' => t('Flash Image Rotator - Jeroen Wijering'), ); $methods[SWFTOOLS_IMAGE_DISPLAY_LIST][WIJERING_IMAGEROTATOR] = $image_rotator; return $methods; } /** * Implementation of hook_menu(). */ function wijering_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array('path' => 'admin/media/swf/wijering', 'title' => t('Wijering Flash'), 'callback' => 'drupal_get_form', 'callback arguments' => 'wijering_admin_form', 'description' => 'Plug-in for '. l('Jeroen Wijering\'s Media Player', 'http://jeroenwijering.com/?item=Flash_Media_Player') .'.', ); } return $items; } function wijering_admin_form() { drupal_set_title('Jeroen Wijering - Flash Players'); include_once(drupal_get_path('module', 'wijering') .'/wijering.admin.inc'); return _wijering_admin_form(); } function wijering_admin_form_submit($form_id, &$form_values) { include_once(drupal_get_path('module', 'wijering') .'/wijering.admin.inc'); return _wijering_admin_form_submit($form_id, $form_values); } /** * These are the default settings as they are stored in the database and displayed * on the settings page. */ function _wijering_settings($player) { $opts = _wijering_options(); switch ($player) { case WIJERING_MEDIAPLAYER: // Define the settings list. $defaults['boolean'] = array( 'largecontrols' => 'default', 'shuffle' => 'default', 'linkfromdisplay' => 'default', 'usecaptions' => 'default', 'usefullscreen' => 'default', 'usekeys' => 'default', 'autoscroll' => 'default', 'showdigits' => 'default', 'showeq' => 'default', 'showicons' => 'default', 'thumbsinplaylist' => 'default', 'autostart' => 'default', 'enablejs' => 'default', ); $defaults['color'] = array( 'backcolor' => '', 'frontcolor' => '', 'lightcolor' => '', ); $defaults['url'] = array( 'logo' => '', 'callback' => '', 'captions' => '', 'fsbuttonlink' => '', 'link' => '', 'streamscript' => '', ); $defaults['integer'] = array( 'width' => '400', 'height' => '320', 'displayheight' => '', 'displaywidth' => '', // default is blank, otherwise overrides 'displayheight' 'bufferlength' => '', 'rotatetime' => '', 'volume' => '', ); $defaults['other'] = array( 'type' => '', // Defaults to the filename extension. 'repeat' => 'default', // This false is part of {true,false,list} 'linktarget' => 'default', 'overstretch' => 'default', ); $saved_settings = variable_get('swftools_'. WIJERING_MEDIAPLAYER, array()); break; case WIJERING_IMAGEROTATOR: // Define the settings list. $defaults['boolean'] = array( 'shuffle' => 'default', 'shownavigation' => 'default', 'linkfromdisplay' => 'default', 'showicons' => 'default', 'enablejs' => 'default', ); $defaults['color'] = array( 'backcolor' => '', 'frontcolor' => '', 'lightcolor' => '', ); $defaults['url'] = array( 'logo' => '', 'link' => '', ); $defaults['integer'] = array( 'width' => '400', 'height' => '320', 'rotatetime' => '3', ); $defaults['other'] = array( 'transition' => 'default', 'linktarget' => 'default', 'overstretch' => 'default', ); $saved_settings = variable_get('swftools_'. WIJERING_IMAGEROTATOR, array()); break; } // Overwrite initialised variables with those that might be already saved. foreach ($defaults AS $category => $vars) { foreach ($vars AS $key => $setting) { if (isset($saved_settings[$key])) { $defaults[$category][$key] = $saved_settings[$key]; } } } return $defaults; } /** * Implementation of swftools_flashvars hook. * Return an array of flashvars. */ function wijering_swftools_flashvars($action, &$methods, &$vars) { // Pad out the user parameters (like those passed through swf(), with our // configured defaults, allowing the user parameters to dominate. $saved_settings = _wijering_flashvars($methods->player['name']); $saved = array(); foreach ($saved_settings AS $category => $settings) { $saved = array_merge($saved, $settings); } $flashvars = array_merge($saved, $vars->flashvars); if (isset($flashvars['image']) && !valid_url($flashvars['image'], TRUE)) { $flashvars['image'] = swftools_get_media_url(swftools_get_media_path() .'/'. $flashvars['image']); } if ($vars->params['width']) {$flashvars['width'] = $vars->params['width'];} if ($vars->params['height']) {$flashvars['height'] = $vars->params['height'];} // Return an array of flash variables return $flashvars; } /** * This function is called from wijering_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 _wijering_settings(). Then we prepare these values for output * to html (eg. '1' become 'true') and we unset undefined flashvars to prevent their output. * */ function _wijering_flashvars($this_player) { // Cache this. static $flashvars = array(); if (!count($flashvars)) { // Media Player foreach (array(WIJERING_MEDIAPLAYER, WIJERING_IMAGEROTATOR) AS $player) { // Get saved settings for this method. $defaults = _wijering_settings($player); foreach ($defaults AS $category => $vars) { foreach ($vars AS $key => $setting) { if (!$setting || $setting == 'default') { unset($defaults[$category][$key]); } else { switch ($category) { case 'color': $defaults['color'][$key] = str_replace('#', '0x', $defaults['color'][$key]); break; case 'boolean': $defaults['boolean'][$key] = _swftools_tf($defaults['boolean'][$key]); break; } } } } // Not the same as width/height. This determines the extended width OR height // past the main view area where the actual playlist file names can be found. // Setting both together is not supported. if ($defaults['integer']['displaywidth']) { unset($defaults['integer']['displayheight']); } else { unset($defaults['integer']['displaywidth']); } $flashvars[$player] = $defaults; } } return $flashvars[$this_player]; } /** * flashvar and param option arrays. These are used for options settings in the * configuration screen. * */ function _wijering_options() { $options['overstretch'] = array('default' => 'default', 'false' => 'false', 'true' => 'true', 'fit' => 'fit', 'none' => 'none', ); $options['repeat'] = array('default' => 'default', 'false' => 'false', 'true' => 'true', 'list' => 'list', ); $options['linktarget'] = array('default' => 'default', '_self' => '_self', '_blank' => '_blank', ); $options['transition'] = array('default' => 'default', 'fade' => 'fade', 'bgfade' => 'bgfade', 'blocks' => 'blocks', 'circles' => 'circles', 'fluids' => 'fluids', 'lines' => 'lines', 'random' => 'random', ); $options['bool'] = array('default' => 'default', 'true' => 'true', 'false' => 'false'); return $options; } function swftools_wijering_mediaplayer_playlist($xml_data, &$method, &$vars) { $xml = ' '. $xml_data['header']['title'] .' '; foreach ($xml_data['playlist'] AS $track => $details) { if (!isset($details['background']) && strtolower(substr($details['fileurl'], -3, 3)) == 'mp3') { if (isset($vars->flashvars['image'])) { $details['background'] = swftools_get_media_url(swftools_get_media_path() .'/'. $vars->flashvars['image']); } else { $details['background'] = SWFTOOLS_DEFAULT_BG; } } $xml .= "\n"; $xml .= "". $details['title'] ."\n"; $xml .= "\n"; $xml .= "". $details['fileurl'] ."\n"; $xml .= "". $details['background'] ."\n"; $xml .= "". $details['fileurl'] ."\n"; $xml .= "\n"; } $xml .= ' '; return $xml; } function swftools_wijering_imagerotator_playlist($xml_data, &$method, &$vars) { $xml = ' '. $xml_data['header']['title'] .' '; foreach($xml_data['playlist'] AS $track => $details) { $xml .= "\n"; $xml .= "". $details['title'] ."\n"; $xml .= "\n"; $xml .= "". $details['fileurl'] ."\n"; $xml .= "". $details['fileurl'] ."\n"; $xml .= "\n"; } $xml .= ' '; return $xml; } /** * Call swf(), enforcing the wijering media player, for a single file. * Parameters and calling are identical to swf() */ function wijering_mediaplayer_swf($filepath, $params = SWFDEFAULT, $flashvars = SWFDEFAULT, $othervars = SWFDEFAULT, $methods = array()) { $methods['player'] = WIJERING_MEDIAPLAYER; return swf($filepath, $params, $flashvars, $othervars, $methods); } /** * Call swf(), enforcing the wijering media player, for a list of files (like a playlist) * Parameters and calling are identical to swf_list() */ function wijering_mediaplayer_swf_list($playlist_data, $params = SWFDEFAULT, $flashvars = SWFDEFAULT, $othervars = SWFDEFAULT, $methods = array()) { $methods['player'] = WIJERING_MEDIAPLAYER; return swf_list($playlist_data, $params, $flashvars, $othervars, $methods); } /** * Call swf(), enforcing the image rotator, for a single file (a pre-saved xml file) * Parameters are identical to swf() */ function wijering_imagerotator_swf($filepath, $params = SWFDEFAULT, $flashvars = SWFDEFAULT, $othervars = SWFDEFAULT, $methods = SWFDEFAULT, $debug = FALSE) { $methods['player'] = WIJERING_IMAGEROTATOR; return swf($playlist_data, $params, $flashvars, $othervars, $methods); } /** * Call swf(), enforcing the wijering media player, for a list of files (like a playlist) * Parameters and calling are identical to swf_list() */ function wijering_imagerotator_swf_list($playlist_data, $params = SWFDEFAULT, $flashvars = SWFDEFAULT, $othervars = SWFDEFAULT, $methods = array()) { $methods['player'] = WIJERING_IMAGEROTATOR; return swf_list($playlist_data, $params, $flashvars, $othervars, $methods); } /* * Implementation of hook_swftools_variable_mapping. * */ function wijering_swftools_variable_mapping() { return array( WIJERING_MEDIAPLAYER => array( 'autostart' => 'flashvars', 'repeat' => 'flashvars', 'rotatetime' => 'flashvars', 'backcolor' => 'flashvars', 'frontcolor' => 'flashvars', 'lightcolor' => 'flashvars', 'displaywidth' => 'flashvars', 'displayheight' => 'flashvars', 'image' => 'flashvars', ), WIJERING_IMAGEROTATOR => array( 'transition' => 'flashvars', 'rotatetime' => 'flashvars', 'backcolor' => 'flashvars', 'frontcolor' => 'flashvars', 'lightcolor' => 'flashvars', ), ); }