/[drupal]/contributions/modules/swftools/genericplayers.module
ViewVC logotype

Contents of /contributions/modules/swftools/genericplayers.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Fri Mar 6 19:48:00 2009 UTC (8 months, 3 weeks ago) by stuartgreenfield
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +8 -13 lines
File MIME type: text/x-php
Accidentally committed a version that wasn't intended. This (hopefully) reverses the error.
1 <?php
2 // $Id: genericplayers.module,v 1.4 2009/03/06 16:45:46 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 define('GENERIC_FLV', 'generic_flv'); // Play an flv file
15 define('GENERIC_MP3', 'generic_mp3'); // Play an mp3.
16
17 /**
18 * Implementation of hook_swftools_methods().
19 */
20 function genericplayers_swftools_methods() {
21
22 $methods = array();
23
24 $mp3_player = array (
25 'name' => GENERIC_MP3,
26 'module' => 'genericplayers',
27 'file' => 'file_url', // Define which flashvar to assign a 'file to play' variable.
28 'shared_file' => 'generic/generic_mp3.swf',
29 'title' => t('Generic MP3 player'),
30 );
31
32 $methods[SWFTOOLS_MP3_DISPLAY][GENERIC_MP3] = $mp3_player;
33
34 $flv_player = array (
35 'name' => GENERIC_FLV,
36 'module' => 'genericplayers',
37 'file' => 'file_url', // Define which flashvar to assign a 'file to play' variable.
38 'shared_file' => 'generic/generic_flv.swf',
39 'title' => t('Generic FLV player'),
40 );
41
42 $methods[SWFTOOLS_FLV_DISPLAY][GENERIC_FLV] = $flv_player;
43
44 return $methods;
45 }
46
47
48 /**
49 * Implementation of hook_menu(). Items such as access control is set by swftools automatically
50 * This is not a "true" hook, but the contents returned by this function are merged with
51 * swftools_menu to provide the complete menu structure for SWF Tools
52 */
53 function genericplayers_menu() {
54
55 $items = array();
56
57 //$items['admin/media/swf/generic'] = array(
58 $items['admin/settings/swftools/generic'] = array(
59 'title' => 'Generic players',
60 'description' => 'Basic Flash players that ship with SWF Tools',
61 'access arguments' => array('administer flash'),
62 'weight' => -1,
63 'page callback' => 'drupal_get_form',
64 'page arguments' => array('swftools_admin_generic_form'),
65 );
66 return $items;
67 }
68
69
70 /**
71 * Implementation of swftools_admin_hook_form.
72 * Return the system settings page for generic players
73 */
74 function swftools_admin_generic_form() {
75
76 $form = array();
77
78 $methods = swftools_methods_available(SWFTOOLS_EMBED);
79
80 $form['generic_mp3_autostart'] = array(
81 '#type' => 'checkbox',
82 '#default_value' => variable_get('generic_mp3_autostart', FALSE),
83 '#title' => t('Autostart MP3 files'),
84 '#description' => t('Automatically start playing MP3 files.'),
85 );
86
87 $form['generic_flv_autostart'] = array(
88 '#type' => 'checkbox',
89 '#default_value' => variable_get('generic_flv_autostart', TRUE),
90 '#title' => t('Autostart FLV files'),
91 '#disabled' => TRUE, // Generic player always autoplays
92 '#description' => t('Automatically start playing FLV files.<br />
93 This option cannot be changed as the generic player
94 always automatically starts playing FLV files.
95 '),
96 );
97
98 return system_settings_form($form);
99 }
100
101
102 /**
103 * Implementation of swftools_flashvars hook.
104 *
105 */
106 function genericplayers_swftools_flashvars($action, &$methods, &$vars) {
107 // All we need to do is assign the 'file_url' variable to our preferred place on the flashvars array.
108 if ($vars->othervars['file_url']) {
109 $vars->flashvars['file_url'] = $vars->othervars['file_url'];
110 }
111
112 switch ($action) {
113 case SWFTOOLS_MP3_DISPLAY:
114 $vars->flashvars['autostart'] = (isset($vars->flashvars['autostart'])) ? ($vars->flashvars['autostart']) : variable_get('generic_mp3_autostart', FALSE) ? 'true' : 'false';
115 break;
116 case SWFTOOLS_FLV_DISPLAY:
117 $vars->flashvars['autostart'] = (isset($vars->flashvars['autostart'])) ? ($vars->flashvars['autostart']) : variable_get('generic_flv_autostart', FALSE) ? 'true' : 'false';
118 break;
119 }
120 return $vars->flashvars;
121 }

  ViewVC Help
Powered by ViewVC 1.1.2