/[drupal]/contributions/modules/emfield/contrib/video_cck/providers/livevideo.inc
ViewVC logotype

Contents of /contributions/modules/emfield/contrib/video_cck/providers/livevideo.inc

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


Revision 1.4 - (show annotations) (download) (as text)
Mon May 12 04:10:54 2008 UTC (18 months, 2 weeks ago) by alexua
Branch: MAIN
CVS Tags: DRUPAL-5--1-3, HEAD
Changes since 1.3: +2 -2 lines
File MIME type: text/x-php
Corrected all errors registered by Coder module in preperation for D6 port
1 <?php
2 // $Id: livevideo.inc,v 1.3 2007/09/06 22:18:25 aaron Exp $
3
4 define('VIDEO_CCK_LIVEVIDEO_MAIN_URL', 'http://www.livevideo.com/');
5 define('VIDEO_CCK_LIVEVIDEO_API_INFO', 'http://www.livevideo.com/api/default.aspx');
6 define('VIDEO_CCK_LIVEVIDEO_API_APPLICATION_URL', 'http://www.livevideo.com/profile/admin/editdeveloperprofile.aspx');
7 define('VIDEO_CCK_LIVEVIDEO_REST_ENDPOINT', 'http://www.livevideo.com/api/');
8
9 /**
10 * hook video_cck_PROVIDER_info
11 * this returns information relevant to a specific 3rd party video provider
12 * @return
13 * an array of strings requested by various admin and other forms
14 * 'name' => the translated name of the provider
15 * 'url' => the url to the main page for the provider
16 * 'settings_description' => a description of the provider that will be posted in the admin settings form
17 * 'supported_features' => an array of rows describing the state of certain supported features by the provider.
18 * These will be rendered in a table, with the columns being 'Feature', 'Supported', 'Notes'.
19 */
20 function video_cck_livevideo_info() {
21 $name = t('Live Video');
22 $features = array(
23 array(t('Autoplay'), t('Yes'), ''),
24 array(t('RSS Attachment'), t('No'), ''),
25 array(t('Thumbnails'), t('Yes'), ''),
26 );
27 return array(
28 'provider' => 'livevideo',
29 'name' => $name,
30 'url' => VIDEO_CCK_LIVEVIDEO_MAIN_URL,
31 'settings_description' => t('These settings specifically affect videos displayed from !livevideo. You can learn more about its !api here.', array('!livevideo' => l($name, VIDEO_CCK_LIVEVIDEO_MAIN_URL, array('target' => '_blank')), '!api' => l(t('API'), VIDEO_CCK_LIVEVIDEO_API_INFO, array('target' => '_blank')))),
32 'supported_features' => $features,
33 );
34 }
35
36 /**
37 * hook video_cck_PROVIDER_settings
38 * this should return a subform to be added to the video_cck_settings() admin settings page.
39 * note that a form field will already be provided, at $form['PROVIDER'] (such as $form['livevideo'])
40 * so if you want specific provider settings within that field, you can add the elements to that form field.
41 */
42 function video_cck_livevideo_settings() {
43 $form['livevideo']['api'] = array(
44 '#type' => 'fieldset',
45 '#title' => t('Live Video API'),
46 '#description' => t('If you wish to be able to display Live Video thumbnails automatically, you will first need to apply for an API Developer Key from the !livevideo. Note that you do not need this key to display Live Video videos themselves.', array('!livevideo' => l('Live Video Developer Profile page', VIDEO_CCK_LIVEVIDEO_API_APPLICATION_URL, array('target' => '_blank')))),
47 '#collapsible' => true,
48 '#collapsed' => true,
49 );
50 $form['livevideo']['api']['video_cck_livevideo_api_key'] = array(
51 '#type' => 'textfield',
52 '#title' => t('Live Video API Key'),
53 '#default_value' => variable_get('video_cck_livevideo_api_key', ''),
54 '#description' => t('Please enter your Live Video Developer Key here.'),
55 );
56 return $form;
57 }
58
59 /**
60 * this is a wrapper for video_cck_request_xml that includes livevideo's api key
61 */
62 function video_cck_livevideo_request($method, $args = array(), $cached = true) {
63 $args['developerId'] = trim(variable_get('video_cck_livevideo_api_key', ''));
64
65 $request = module_invoke('emfield', 'request_xml', 'livevideo', VIDEO_CCK_LIVEVIDEO_REST_ENDPOINT . $method, $args, $cached);
66 return $request;
67 }
68
69 /**
70 * hook video_cck_PROVIDER_extract
71 * this is called to extract the video code from a pasted URL or embed code.
72 * @param $embed
73 * an optional string with the pasted URL or embed code
74 * @return
75 * either an array of regex expressions to be tested, or a string with the video code to be used
76 * if the hook tests the code itself, it should return either the string of the video code (if matched), or an empty array.
77 * otherwise, the calling function will handle testing the embed code against each regex string in the returned array.
78 */
79 function video_cck_livevideo_extract($embed = '') {
80 // <div><embed src="http://www.livevideo.com/flvplayer/embed/591C1350DD174FE0B10C4DCFC88981DA" type="application/x-shockwave-flash" quality="high" WIDTH="445" HEIGHT="369" wmode="transparent"></embed><br/><a href="http://www.livevideo.com/video/embedLink/591C1350DD174FE0B10C4DCFC88981DA/236172/mascot-bloopers-video.aspx">Mascot Bloopers Video</a></div>
81 // http://www.livevideo.com/video/591C1350DD174FE0B10C4DCFC88981DA/mascot-bloopers-video.aspx
82 // NOTE: the order of the following matters very much in this case...
83 return array(
84 '@livevideo\.com/flvplayer/embed/([^\"]*)\"@i',
85 '@livevideo\.com/video/([^/]*)/@i',
86 );
87 }
88
89 /**
90 * hook video_cck_PROVIDER_embedded_link($video_code)
91 * returns a link to view the video at the provider's site
92 * @param $video_code
93 * the string containing the video to watch
94 * @return
95 * a string containing the URL to view the video at the original provider's site
96 */
97 function video_cck_livevideo_embedded_link($video_code) {
98 $method = 'GetVideoDetails.ashx';
99 $args = array('videoId' => $video_code);
100 $request = video_cck_livevideo_request($method, $args);
101 $url = $request['VIDEODETAILS']['VIEWURL'][0];
102 return $url;
103 }
104
105 /**
106 * the embedded flash displaying the livevideo video
107 */
108 function theme_video_cck_livevideo_flash($embed, $width, $height, $autoplay) {
109 if ($embed) {
110 $autostart = $autoplay ? '&autoStart=1' : '';
111 $output .= '<embed src="http://www.livevideo.com/flvplayer/embed/'. $embed . $autostart .'" type="application/x-shockwave-flash" quality="high" WIDTH="'. $width .'" HEIGHT="'. $height .'" wmode="transparent"></embed>';
112 }
113 return $output;
114 }
115
116 /**
117 * hook video_cck_PROVIDER_thumbnail
118 * returns the external url for a thumbnail of a specific video
119 * TODO: make the args: ($embed, $field, $item), with $field/$item provided if we need it, but otherwise simplifying things
120 * @param $field
121 * the field of the requesting node
122 * @param $item
123 * the actual content of the field from the requesting node
124 * @return
125 * a URL pointing to the thumbnail
126 */
127 function video_cck_livevideo_thumbnail($field, $item, $formatter, $node, $width, $height) {
128 $method = 'GetVideoDetails.ashx';
129 $args = array('videoId' => $item['value']);
130 $request = video_cck_livevideo_request($method, $args);
131 $tn = $request['VIDEODETAILS']['DEFAULTTHUMBNAIL'][0];
132 return $tn;
133 }
134
135 /**
136 * hook video_cck_PROVIDER_video
137 * this actually displays the full/normal-sized video we want, usually on the default page view
138 * @param $embed
139 * the video code for the video to embed
140 * @param $width
141 * the width to display the video
142 * @param $height
143 * the height to display the video
144 * @param $field
145 * the field info from the requesting node
146 * @param $item
147 * the actual content from the field
148 * @return
149 * the html of the embedded video
150 */
151 function video_cck_livevideo_video($embed, $width, $height, $field, $item, $autoplay) {
152 $output = theme('video_cck_livevideo_flash', $embed, $width, $height, $autoplay);
153 return $output;
154 }
155
156 /**
157 * hook video_cck_PROVIDER_video
158 * this actually displays the preview-sized video we want, commonly for the teaser
159 * @param $embed
160 * the video code for the video to embed
161 * @param $width
162 * the width to display the video
163 * @param $height
164 * the height to display the video
165 * @param $field
166 * the field info from the requesting node
167 * @param $item
168 * the actual content from the field
169 * @return
170 * the html of the embedded video
171 */
172 function video_cck_livevideo_preview($embed, $width, $height, $field, $item, $autoplay) {
173 $output = theme('video_cck_livevideo_flash', $embed, $width, $height, $autoplay);
174 return $output;
175 }

  ViewVC Help
Powered by ViewVC 1.1.2