FLOWPLAYER3_MEDIAPLAYER, 'module' => 'flowplayer3', 'file' => '', // Return nothing - do not make a file assignment 'version' => '9', 'shared_file' => 'flowplayer3/' . variable_get('flowplayer3_mediaplayer_file', FLOWPLAYER3_MEDIAPLAYER_FILE), 'title' => t('FlowPlayer 3'), 'download' => 'http://flowplayer.org/', ); /** * Define actions that the player can support by returning an array with keys * [action][name_of_player][player_details] */ $methods[SWFTOOLS_FLV_DISPLAY][FLOWPLAYER3_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_FLV_DISPLAY_LIST][FLOWPLAYER3_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MP3_DISPLAY][FLOWPLAYER3_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MP3_DISPLAY_LIST][FLOWPLAYER3_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MEDIA_DISPLAY][FLOWPLAYER3_MEDIAPLAYER] = $media_player; $methods[SWFTOOLS_MEDIA_DISPLAY_LIST][FLOWPLAYER3_MEDIAPLAYER] = $media_player; // Return the method results return $methods; } /** * Implementation of hook_menu(). */ function flowplayer3_menu() { $items = array(); $items['admin/settings/swftools/flowplayer3'] = array( 'title' => 'FlowPlayer 3', 'description' => 'Settings for ' . l('FlowPlayer 3', FLOWPLAYER3_DOWNLOAD) . '.', 'access arguments' => array('administer flash'), 'page callback' => 'drupal_get_form', 'page arguments' => array('flowplayer3_admin_settings'), 'file' => 'flowplayer3.admin.inc', 'file path' => drupal_get_path('module', 'flowplayer3'), ); return $items; } /** * Implementation of swftools_flashvars hook(). * Note that $methods and $vars are passed by reference, so the player module * can manipulate them directly if necessary. * @param $action * String defining the action that is to be performed, eg SWFTOOLS_FLV_DISPLAY * @param &$methods * Object containing two keys - player and method. Each consists of an array * that defines the details of the resolved player and embedding method that * is being used for this file. * @param &$vars * Object containing three keys - othervars, flashvars and params. These are * arrays containing key/value pairs that contain all the data assigned to this * file so far. Refer to swf() for more details about the $vars array. * @return * Return an array of flashvars needed to allow the player to work. */ function flowplayer3_swftools_flashvars($action, &$methods, &$vars) { // Initialise array of FlowPlayer3 configuration settings $flowplayer = array(); // Initialise array to hold data $playlist = array(); // Is this file to be streamed? Check for the stream variable being set if (isset($vars->othervars['stream'])) { // Extract path info from the $file_url variable describing the file $info = pathinfo($vars->othervars['file_url']); // Replace the current (non streamed) file url with the stream filename $vars->othervars['file_url'] = $info['basename']; } // // If an image was supplied to be the splash then put this first in the list // // This code doesn't seem to be working - the player objects to { url: '' } // if (isset($vars->othervars['image'])) { // //$playlist[] = "'" . $vars->othervars['image'] . "'"; // $playlist[] = "{ url: '" . $vars->othervars['image'] . "' }"; // } // If the passed variables includes 'playlist_data' we have a playlist if (isset($vars->othervars['playlist_data'])) { // Get file paths out of the playlist_data array and add to FlowPlayer playlist foreach ($vars->othervars['playlist_data']['playlist'] as $play) { $playlist[] = "'" . $play['fileurl'] . "'"; } } else { // Not a playlist, so populate FlowPlayer3 playlist with the file_url $playlist[] = "'" . $vars->othervars['file_url'] . "'"; } // Implode the array to create a string ready for later $flowplayer['playlist'] = '[ ' . implode(', ', $playlist) . ' ]'; // Retrieve the current FlowPlayer3 settings $saved_settings = _flowplayer3_settings(); // Scan through each setting to see if it is over-ridden in $vars->othervars // Unset properties that are blank to keep the resulting code 'tidy' foreach ($saved_settings as $category => $data) { foreach ($data as $property => $value) { if (isset($vars->othervars[$property])) { $saved_settings[$category][$property] = $vars->othervars[$property]; } if (!$saved_settings[$category][$property]) { unset($saved_settings[$category][$property]); } } } // Add the properties to the flowplayer array ready for rendering $flowplayer['canvas'] = $saved_settings['canvas']; $flowplayer['clip'] = $saved_settings['clip']; $flowplayer['plugins']['controls'] = $saved_settings['controls']; // If we are streaming this file, add the stream plugin if (isset($vars->othervars['stream'])) { // Define the clip provider as 'stream' $flowplayer['clip']['provider'] = 'stream'; // Get the name of the stream plugin $flowplayer['plugins']['stream']['url'] = variable_get('flowplayer3_mediaplayer_stream_plugin', FLOWPLAYER3_MEDIAPLAYER_STREAM_PLUGIN); // Set the path to the source of the stream $flowplayer['plugins']['stream']['netConnectionUrl'] = $vars->othervars['stream']; } // Convert flowplayer array to JSON, and assign to a flashvar called config $flashvars['config'] = drupal_to_js($flowplayer); // Replace " with ', and remove quotes from around true and false, to satisfy FlowPlayer $flashvars['config'] = str_replace(array('"', "'false'", "'true'", "'[", "]'"), array("'", "false", "true", "[", "]"), $flashvars['config']); // The ' has been escaped, so reverse it where it occurs in the playlist (it gets escaped again later!) $flashvars['config'] = str_replace(array("\'"), array("'"), $flashvars['config']); // Return the finished array of flash variables return $flashvars; } /** * Implementation of hook_{player}_swftools_playlist(). * This function builds the content needed to write to an xml playlist. In the * case of FlowPlayer3 it is not actually necessary to produce an xml playlist, * but we must support this hook as SWF Tools uses its presence to detect that * the player is capable of supporting playlists. * DO WE NEED TO DO THIS? IF THE PLAYER DOESN'T SUPPORT LIST ACTIONS THEN WE ALREADY KNOW THIS? * * @param $xml_data * Array of data that can be used to build the xml playlist. Contains keys * [header][title] Title data that can be used for the playlist * [playlist][key][filepath] The filepath to the file * [playlist][key][filename] The filename of the file * [playlist][key][fileurl] The url of the file * [playlist][key][title] The title of the file * [action] The action to be performed by this playlist (e.g. SWFTOOLS_MP3_DISPLAY_LIST) * @param $method * Object containing two keys - player and method. Each consists of an array * that defines the details of the resolved player and embedding method that * is being used for this file. * @param $vars * Object containing three keys - othervars, flashvars and params. These are * arrays containing key/value pairs that contain all the data assigned to this * file so far. THE ARRAY othervars CONTAINS A KEY playlist_data THAT APPEARS * TO REPEAT THE CONTENTS OF xml_data. IS IT NECESSARY TO PASS BOTH? * @return * String of text that be written to the xml file defining the playlist. */ function flowplayer3_flowplayer3_mediaplayer_swftools_playlist($xml_data, &$method, &$vars) { // For FlowPlayer3 return nothing and let the handler create an empty xml file return; } /* * Implementation of hook_swftools_variable_mapping(). * * @return * Array of data describing how parameters passed to the player should be * mapped. The first keys describe the name of the player, and this contains * a sub-array that consists of key/value pairs. The key describes the name * of the parameter, the value describes what it maps to, e.g. flashvars */ function flowplayer3_swftools_variable_mapping() { // FlowPlayer3 doesn't need to make any variable mappings return array( FLOWPLAYER3_MEDIAPLAYER => array(), ); } /** * Return player configurations settings that will be used if not over-ridden. * * @return * Because there are so many settings for FlowPlayer3 the defaults are defined * in the array returned by this function. The function initialises an array * of defaults, merges settings from the configuration page, and returns the * result. */ function _flowplayer3_settings() { // Define the settings list $defaults['clip'] = array( 'autoPlay' => 'false', 'autoBuffering' => 'false', 'scaling' => 'scale', 'start' => '', 'duration' => '', 'accelerated' => 'false', 'bufferLength' => '', 'provider' => '', 'fadeInSpeed' => '', 'fadeOutSpeed' => '', 'linkUrl' => '', 'linkWindow' => '_blank', 'live' => 'false', 'cuePointMultiplier' => '', ); $defaults['controls'] = array( 'timeColor' => '#01DAFF', 'durationColor' => '#FFFFFF', 'progressColor' => '#015B7A', 'progressGradient' => 'medium', 'bufferColor' => '#6C9CBC', 'bufferGradient' => 'none', 'sliderColor' => '#000000', 'sliderGradient' => 'none', 'buttonColor' => '#889AA4', 'buttonOverColor' => '#92B2BD', 'autoHide' => 'fullscreen', 'play' => 'true', 'volume' => 'true', 'mute' => 'true', 'time' => 'true', 'stop' => 'false', 'playlist' => 'false', 'fullscreen' => 'true', 'scrubber' => 'true', 'top' => '', 'left' => '', 'bottom' => '', 'right' => '', 'opacity' => '', ); $defaults['canvas'] = array( 'backgroundColor' => '#000000', 'backgroundImage' => '', 'backgroundRepeat' => 'repeat', 'backgroundGradient' => 'low', 'border' => '', 'borderRadius' => '', ); // Retrieve settings from database, if available $saved_settings = variable_get(FLOWPLAYER3_MEDIAPLAYER, array()); // Merge the two sets together $defaults = array_merge($defaults, $saved_settings); // Return resulting defaults return $defaults; } /** * Implementation of hook_help(). */ function flowplayer3_help($path, $arg) { switch ($path) { case 'admin/settings/swftools/flowplayer3': return '
' . t('These are the settings for the FlowPlayer 3 media player. For details of what each parameter does refer to the FlowPlayer 3 documentation. It is possible that you do not need to change any of these settings and blank values will use FlowPlayer defaults. 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('@flowplayer' => 'http://flowplayer.org/demos/index.html')) . '
'; } }