| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: genericplayers.module,v 1.3 2008/10/03 23:20:32 stuartgreenfield Exp $ 3 4 /** 5 * 6 * Support for generic Flash player for SWF Tools 7 * 8 * Please note: This module does not need to be installed (hence no .info file). 9 * It is included automatically by swftools.module. It is uses the ".module" naming 10 * syntax because it serves as a tutorial module for creating your own Flash Player integration 11 * module. 12 */ 13 14 /** 15 * Implementation of swftools_methods hook 16 * Report methods back to SWF Tools 17 */ 18 19 define('GENERIC_FLV', 'generic_flv'); // Play an flv file 20 define('GENERIC_MP3', 'generic_mp3'); // Play an mp3. 21 22 function genericplayers_swftools_methods() { 23 24 $methods = array(); 25 26 $mp3_player = array ( 27 'name' => GENERIC_MP3, 28 'module' => 'genericplayers', 29 'file' => 'file_url', // Define which flashvar to assign a 'file to play' variable. 30 'shared_file' => 'generic/generic_mp3.swf', 31 'title' => t('Generic MP3 player'), 32 ); 33 34 $methods[SWFTOOLS_MP3_DISPLAY][GENERIC_MP3] = $mp3_player; 35 36 $flv_player = array ( 37 'name' => GENERIC_FLV, 38 'module' => 'genericplayers', 39 'file' => 'file_url', // Define which flashvar to assign a 'file to play' variable. 40 'shared_file' => 'generic/generic_flv.swf', 41 'title' => t('Generic FLV player'), 42 ); 43 44 $methods[SWFTOOLS_FLV_DISPLAY][GENERIC_FLV] = $flv_player; 45 46 return $methods; 47 } 48 49 50 /** 51 * Implementation of hook_menu(). Items such as access control is set by swftools automatically 52 * This is not a "true" hook, but the contents returned by this function are merged with 53 * swftools_menu to provide the complete menu structure for SWF Tools 54 */ 55 function genericplayers_menu() { 56 57 $items = array(); 58 59 //$items['admin/media/swf/generic'] = array( 60 $items['admin/settings/swftools/generic'] = array( 61 'title' => 'Generic players', 62 'description' => 'Basic Flash players that ship with SWF Tools', 63 'access arguments' => array('administer flash'), 64 'weight' => -1, 65 'page callback' => 'drupal_get_form', 66 'page arguments' => array('swftools_admin_generic_form'), 67 ); 68 return $items; 69 } 70 71 72 /** 73 * Implementation of swftools_admin_hook_form. 74 * Return the system settings page for generic players 75 */ 76 function swftools_admin_generic_form() { 77 78 $form = array(); 79 80 $methods = swftools_methods_available(SWFTOOLS_EMBED_METHOD); 81 82 $form['generic_mp3_autostart'] = array( 83 '#type' => 'checkbox', 84 '#default_value' => variable_get('generic_mp3_autostart', FALSE), 85 '#title' => t('Autostart MP3 files'), 86 '#description' => t('Automatically start playing MP3 files.'), 87 ); 88 89 $form['generic_flv_autostart'] = array( 90 '#type' => 'checkbox', 91 '#default_value' => variable_get('generic_flv_autostart', TRUE), 92 '#title' => t('Autostart FLV files'), 93 '#disabled' => TRUE, // Generic player always autoplays 94 '#description' => t('Automatically start playing FLV files.<br /> 95 This option cannot be changed as the generic player 96 always automatically starts playing FLV files. 97 '), 98 ); 99 100 return system_settings_form($form); 101 } 102 103 104 /** 105 * Implementation of swftools_flashvars hook. 106 * 107 */ 108 function genericplayers_swftools_flashvars($action, &$methods, &$vars) { 109 // All we need to do is assign the 'file_url' variable to our preferred place on the flashvars array. 110 if ($vars->othervars['file_url']) { 111 $vars->flashvars['file_url'] = $vars->othervars['file_url']; 112 } 113 114 switch ($action) { 115 case SWFTOOLS_MP3_DISPLAY: 116 $vars->flashvars['autostart'] = (isset($vars->flashvars['autostart'])) ? ($vars->flashvars['autostart']) : variable_get('generic_mp3_autostart', FALSE) ? 'true' : 'false'; 117 break; 118 case SWFTOOLS_FLV_DISPLAY: 119 $vars->flashvars['autostart'] = (isset($vars->flashvars['autostart'])) ? ($vars->flashvars['autostart']) : variable_get('generic_flv_autostart', FALSE) ? 'true' : 'false'; 120 break; 121 } 122 return $vars->flashvars; 123 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |