genericplayers.module

Tracking 5.x-1.x branch
  1. drupal
    1. 5 contributions/swftools/genericplayers.module

Functions & methods

NameDescription
genericplayers_menuImplementation of hook_menu(). Items such as access control is set by swftools automatically
genericplayers_swftools_flashvarsImplementation of swftools_flashvars hook.
genericplayers_swftools_methods
swftools_admin_generic_formImplementation of swftools_admin_hook_form. Return the system settings page.

Constants

NameDescription
GENERIC_FLV
GENERIC_MP3

File

View source
  1. <?php
  2. /**
  3. *
  4. * Support for generic Flash player for SWF Tools
  5. *
  6. * Please note: This module does not need to be installed (hence no .info file).
  7. * It is included automatically by swftools.module. It is uses the ".module" naming
  8. * syntax because it serves as a tutorial module for creating your own Flash Player integration
  9. * module.
  10. */
  11. /**
  12. * Implementation of swftools_methods hook
  13. * Report methods back to SWF Tools
  14. */
  15. define('GENERIC_FLV', 'generic_flv'); // Play an flv file
  16. define('GENERIC_MP3', 'generic_mp3'); // Play an mp3.
  17. function genericplayers_swftools_methods() {
  18. $methods = array();
  19. $mp3_player = array (
  20. 'name' => GENERIC_MP3,
  21. 'module' => 'genericplayers',
  22. 'file' => 'file_url', // Define which flashvar to assign a 'file to play' variable.
  23. 'shared_file' => 'generic/generic_mp3.swf',
  24. 'title' => t('Generic MP3 Player'),
  25. );
  26. $methods[SWFTOOLS_MP3_DISPLAY][GENERIC_MP3] = $mp3_player;
  27. $flv_player = array (
  28. 'name' => GENERIC_FLV,
  29. 'module' => 'genericplayers',
  30. 'file' => 'file_url', // Define which flashvar to assign a 'file to play' variable.
  31. 'shared_file' => 'generic/generic_flv.swf',
  32. 'title' => t('Generic FLV Player'),
  33. );
  34. $methods[SWFTOOLS_FLV_DISPLAY][GENERIC_FLV] = $flv_player;
  35. return $methods;
  36. }
  37. /**
  38. * Implementation of hook_menu(). Items such as access control is set by swftools automatically
  39. */
  40. function genericplayers_menu($may_cache) {
  41. $items = array();
  42. if ($may_cache) {
  43. $items[] = array('path' => 'admin/media/swf/generic',
  44. 'title' => t('Generic Players'),
  45. 'description' => t('Basic Flash players that ship with SWF Tools'),
  46. 'weight' => -1,
  47. );
  48. }
  49. return $items;
  50. }
  51. /**
  52. * Implementation of swftools_admin_hook_form. Return the system settings page.
  53. */
  54. function swftools_admin_generic_form() {
  55. $form = array();
  56. $methods = swftools_methods_available(SWFTOOLS_EMBED_METHOD);
  57. $form['generic_mp3_autostart'] = array(
  58. '#type' => 'checkbox',
  59. '#default_value' => variable_get('generic_mp3_autostart', FALSE),
  60. '#title' => t('Autostart MP3'),
  61. '#description' => t('Automatically start playing the MP3 file.'),
  62. );
  63. $form['generic_flv_autostart'] = array(
  64. '#type' => 'checkbox',
  65. '#default_value' => variable_get('generic_flv_autostart', FALSE),
  66. '#title' => t('Autostart FLV'),
  67. '#enabled' => FALSE, // Haven't built the FLV Player yet.
  68. '#description' => t('Automatically start playing FLV file.'),
  69. );
  70. return system_settings_form($form);
  71. }
  72. /**
  73. * Implementation of swftools_flashvars hook.
  74. *
  75. */
  76. function genericplayers_swftools_flashvars($action, &$methods, &$vars) {
  77. // All we need to do is assign the 'file_url' variable to our preferred place on the flashvars array.
  78. if ($vars->othervars['file_url']) {
  79. $vars->flashvars['file_url'] = $vars->othervars['file_url'];
  80. }
  81. switch ($action) {
  82. case SWFTOOLS_MP3_DISPLAY:
  83. $vars->flashvars['autostart'] = (isset($vars->flashvars['autostart'])) ? ($vars->flashvars['autostart']) : variable_get('generic_mp3_autostart', FALSE) ? 'true' : 'false';
  84. break;
  85. case SWFTOOLS_FLV_DISPLAY:
  86. $vars->flashvars['autostart'] = (isset($vars->flashvars['autostart'])) ? ($vars->flashvars['autostart']) : variable_get('generic_flv_autostart', FALSE) ? 'true' : 'false';
  87. break;
  88. }
  89. return $vars->flashvars;
  90. }