video_embed_field.api.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * API Info for video_embed_field module
  4. */
  5. /**
  6. * @function hook_video_embed_handler_info
  7. * Can be used to add more handlers for video_embed_field
  8. * @return an array of handlers, each handler is an array with the following keys
  9. * 'title' : required, the untranslated title of the provider, to show to the admin user
  10. * 'function' : required, the function used to generate the embed code
  11. * 'thumbnail_function' : optional, the function used to provide the thumbnail for a video
  12. * 'data_function' : optional, the function to return an array of video data.
  13. * 'form' : required, the function that returns the settings form for your provider
  14. * 'domains' : required, an array of domains to match against, this is used to know which provider to use
  15. * 'defaults' : default values for each setting made configurable in your form function
  16. *
  17. * @see below for function definitions
  18. */
  19. function hook_video_embed_handler_info() {
  20. $handlers = array();
  21. $handlers['ustream'] = array(
  22. 'title' => 'UStream',
  23. 'function' => 'your_module_handle_ustream',
  24. 'thumbnail_function' => 'your_module_handle_ustream_thumbnail',
  25. 'data_function' => 'your_module_handler_ustream_data',
  26. 'form' => 'your_module_handler_ustream_form',
  27. 'domains' => array(
  28. 'ustream.com',
  29. ),
  30. 'defaults' => array(
  31. 'width' => 640,
  32. 'height' => 360,
  33. ),
  34. );
  35. return $handlers;
  36. }
  37. // Example callbacks for a provider (in this case for ustream) - obviously, these functions are only for example
  38. // purposes
  39. /**
  40. * Generate the embed code for a video
  41. * @param $url - the video url as entered by the user
  42. * @param $settings - the settings for this provider as defined in the form function,
  43. * defaulting to your provider's defaults
  44. * @return the embed code as a renderable array
  45. */
  46. function your_module_handle_ustream($url, $settings) {
  47. return array(
  48. //this should be the full embed code for your provider, including each of the settings
  49. '#markup' => '<iframe src="ustream"></iframe>',
  50. );
  51. }
  52. /**
  53. * Retrieve information about the thumbnail for a given url
  54. * @param $url - the url of the video as entered by the user
  55. * @return an array with the keys:
  56. * 'id' => an id for the video which is unique to your provider, used for naming the cached thumbnail file
  57. * 'url' => the url to retrieve the thumbnail from
  58. */
  59. function your_module_handle_ustream_thumbnail ($url) {
  60. return array(
  61. 'id' => '12332243242', //generally the id that the provider uses for the video
  62. 'url' => 'http://something/thumbnail/somthing.jpg', //the url of the thumbnail
  63. );
  64. }
  65. /**
  66. * A forms api callback, returns the settings form for the provider
  67. * @param $defaults - default/current values for your provider, the currently saved settings
  68. * with empty values filled with the defaults provided in info hook
  69. * @return a form as defined by forms api
  70. *
  71. * @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7
  72. */
  73. function your_module_handler_ustream_form($defaults) {
  74. $form = array();
  75. $form['width'] = array(
  76. '#type' => 'textfield',
  77. '#title' => t('Player Width'),
  78. '#description' => t('The width of the player in pixels'),
  79. '#default_value' => $defaults['width'],
  80. );
  81. return $form;
  82. }
  83. /**
  84. * Return an array of extra data to be stored with the video, this data will be available for theming
  85. * @return an array
  86. */
  87. function your_module_handler_ustream_data($url) {
  88. return array();
  89. }