'swftools_onepixelout', 'title' => t('1 Pixel Out MP3 Player'), 'download' => 'http://downloads.wordpress.org/plugin/audio-player.1.2.3.zip', 'width' => 290, 'height' => 24, 'library' => swftools_get_library('audio-player') . '/audio-player/player.swf', ); // Onepixelout support various actions with the same player and info. $methods['audio']['onepixelout'] = $onepixelout; return $methods; } /** * Implementation of hook_menu(). */ function swftools_onepixelout_menu() { $items['admin/settings/swftools/onepixelout'] = array( 'title' => '1 Pixel Out', 'description' => 'Settings for '. l('1 Pixel Out MP3 Player', 'http://downloads.wordpress.org/plugin/audio-player.1.2.3.zip') .'.', 'access arguments' => array('administer flash'), 'page callback' => 'drupal_get_form', 'page arguments' => array('swftools_onepixelout_admin_form'), 'file' => 'swftools_onepixelout.admin.inc', ); return $items; } /** * Returns an array of default settings for the player. */ function _swftools_onepixelout_settings() { // Initialise defaults that apply if no settings were stored $defaults = array( 'height' => 24, 'width' => 290, 'autostart' => 'no', 'loop' => 'no', 'bg' => '', 'leftbg' => '', 'rightbg' => '', 'rightbghover' => '', 'lefticon' => '', 'righticon' => '', 'righticonhover' => '', 'text' => '', 'slider' => '', 'loader' => '', 'track' => '', 'border' => '', ); // Retrieve settings from the database if available $saved = variable_get('swftools_onepixelout', $defaults); // Return result return $saved; } /** * Implementation of hook_swftools_preprocess_[player](). */ function swftools_onepixelout_swftools_preprocess_onepixelout(&$data) { // Generate sequential player ids static $player_id = 1; // Assign a flashvar to identify the player - we add time as well, like swfobject2, to ensure truly unique ids $data['flashvars']['playerID'] = time() . $player_id++; // OnePixelOut needs a playerID, which can only be numeric, but it's easier if div and player had the same id // But then swfobject complains with numeric only ids, so we prepend swf, but keep numbers the same $data['othervars']['id'] = 'swf-' . $data['flashvars']['playerID']; // Retreive default onepixelout settings $saved_settings = _swftools_onepixelout_flashvars(); // Combine user and admin defaults, overwriting defaults. $data['flashvars'] = array_merge($saved_settings, $data['flashvars']); // Attach file url of the content to display to flashvars $data['flashvars']['soundFile'] = $data['othervars']['file_url']; // Put auto-close script on the page swftools_onepixelout_add_js(); } /** * Returns an array of flashvar defaults for the player. */ function _swftools_onepixelout_flashvars() { // Cache this static $settings = array(); // If $settings is empty then retrieve the settings if (!$settings) { // Get saved settings for this method. $settings = _swftools_onepixelout_settings(); // Filter out unassigned or default entries $settings = array_diff($settings, array('', 'default')); } // Return the settings return $settings; } /* * Implementation of hook_swftools_variable_mapping(). */ function swftools_onepixelout_swftools_variable_mapping() { return array( 'onepixelout' => array( 'height' => 'flashvars', 'width' => 'flashvars', 'loop' => 'flashvars', 'autostart' => 'flashvars', 'leftbg' => 'flashvars', 'lefticon' => 'flashvars', 'rightbg' => 'flashvars', 'righticon' => 'flashvars', 'rightbghover' => 'flashvars', 'righticonhover' => 'flashvars', ), ); } /** * Implementation of hook_init(). */ function swftools_onepixelout_init() { if (variable_get('swftools_always_add_js', SWFTOOLS_ALWAYS_ADD_JS)) { swftools_onepixelout_add_js(); } }; /** * Adds OnePixelOut JavaScript to the page. */ function swftools_onepixelout_add_js() { drupal_add_js(drupal_get_path('module', 'swftools_onepixelout') . '/swftools_onepixelout.js'); }