Projet

Général

Profil

Paste
Télécharger (1,89 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / media_youtube / media_youtube.module @ 5e632cae

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides a stream wrapper and formatters appropriate for accessing and
6
 * displaying YouTube videos.
7
 */
8

    
9
// Load all YouTube file formatters.
10
require_once dirname(__FILE__) . '/includes/media_youtube.formatters.inc';
11

    
12
/**
13
 * Implements hook_media_internet_providers().
14
 */
15
function media_youtube_media_internet_providers() {
16
  return array(
17
    'MediaInternetYouTubeHandler' => array(
18
      'title' => t('YouTube'),
19
    ),
20
  );
21
}
22

    
23
/**
24
 * Implements hook_stream_wrappers().
25
 */
26
function media_youtube_stream_wrappers() {
27
  return array(
28
    'youtube' => array(
29
      'name' => t('YouTube videos'),
30
      'class' => 'MediaYouTubeStreamWrapper',
31
      'description' => t('Remote videos hosted on the YouTube video-sharing website.'),
32
      'type' => STREAM_WRAPPERS_READ_VISIBLE,
33
    ),
34
  );
35
}
36

    
37
/**
38
 * Implements hook_theme().
39
 */
40
function media_youtube_theme($existing, $type, $theme, $path) {
41
  return array(
42
    'media_youtube_video' => array(
43
      'variables' => array('uri' => NULL, 'options' => array()),
44
      'file' => 'media_youtube.theme.inc',
45
      'path' => $path . '/themes',
46
      'template' => 'media-youtube-video',
47
    ),
48
  );
49
}
50

    
51
/**
52
 * Implements hook_media_parse().
53
 *
54
 * @todo This hook should be deprecated. Refactor Media module to not call it
55
 * any more, since media_internet should be able to automatically route to the
56
 * appropriate handler.
57
 */
58
function media_youtube_media_parse($embed_code) {
59
  $handler = new MediaInternetYouTubeHandler($embed_code);
60
  return $handler->parse($embed_code);
61
}
62

    
63
/**
64
 * Implements hook_file_mimetype_mapping_alter().
65
 */
66
function media_youtube_file_mimetype_mapping_alter(&$mapping) {
67
  $mapping['mimetypes'][] = 'video/youtube';
68
}
69

    
70
/**
71
 * Implements hook_ctools_plugin_api().
72
 */
73
function media_youtube_ctools_plugin_api($module, $api) {
74
  if ($module == 'file_entity' && $api == 'file_default_displays') {
75
    return array('version' => 1);
76
  }
77
}