'google',
'name' => $name,
'url' => VIDEO_CCK_GOOGLE_MAIN_URL,
'settings_description' => t('These settings specifically affect videos displayed from !google.', array('!google' => l($name, VIDEO_CCK_GOOGLE_MAIN_URL, array('target' => '_blank')))),
'supported_features' => $features,
);
}
function video_cck_google_settings() {
$form = array();
$form['video_cck_google_domain'] = array(
'#type' => 'textfield',
'#title' => t('Google video domain'),
'#default_value' => variable_get('video_cck_google_domain', VIDEO_CCK_GOOGLE_DOMAIN_DEFAULT),
'#description' => t('Google hosts their videos on various servers throughout the world. By default, videos from Google will be displayed from the United States, at their google.com servers. If you wish to display the video from another Google server, please enter the domain here, without the initial dot. For instance, you might enter it for the Italian Google servers at google.it, or ca for their Canadian servers.'),
);
return $form;
}
function video_cck_google_extract($embed) {
return array(
'@http://video\.google(?:\.[a-z]{2,4})+/videoplay\?docid=([^\&]*)\&@i',
'@http://video\.google(?:\.[a-z]{2,4})+/videoplay\?docid=([^\&]*)\&@i',
'@http://video\.google(?:\.[a-z]{2,4})+/videoplay\?docid=(.*)@i',
'@http://video\.google(?:\.[a-z]{2,4})+/googleplayer\.swf\?docId=(-?\d*)@i',
'@http://video\.google(?:\.[a-z]{2,4})+/url\?docid=([^\&]*)\&@i',
);
}
function video_cck_google_request($embed, $cacheable = TRUE) {
$args = array('docid' => $embed);
return module_invoke('emfield', 'request_xml', 'google', VIDEO_CCK_GOOGLE_XML, $args, $cacheable);
}
function video_cck_google_video_link($video_code) {
return 'http://video.google.'. variable_get('video_cck_google_domain', VIDEO_CCK_GOOGLE_DOMAIN_DEFAULT) .'/videoplay?docid='. $video_code;
}
function theme_video_cck_google_flash($embed, $width, $height, $autoplay) {
if ($embed) {
$autoplay = $autoplay ? '&autoPlay=true' : '';
// this will be executed by not Internet Explorer browsers
$output = '
';
}
return $output;
}
/**
* hook emfield_PROVIDER_data
*
* provides an array to be serialised and made available with $item elsewhere
*/
function video_cck_google_data($field, $item) {
$data = array();
// create some 'field' version control
//$data['video_cck_google_version'] = 1;
$rss = video_cck_google_request($item['value']);
if (
is_array($rss['ITEM']) &&
is_array($rss['ITEM']['MEDIA:GROUP']) &&
is_array($rss['ITEM']['MEDIA:GROUP']['MEDIA:CONTENT']) &&
is_array($rss['ITEM']['MEDIA:GROUP']['MEDIA:CONTENT'][1])
) {
$video = $rss['ITEM']['MEDIA:GROUP']['MEDIA:CONTENT'][1];
$data['filepath'] = $video['URL'];
$data['filemime'] = $video['TYPE'];
$data['medium'] = $video['MEDIUM'];
$data['expression'] = $video['EXPRESSION'];
$data['duration'] = $video['DURATION'];
$data['width'] = $video['WIDTH'];
$data['height'] = $video['HEIGHT'];
}
if (is_array($rss['MEDIA:GROUP'])) {
if (is_array($rss['MEDIA:GROUP']['MEDIA:THUMBNAIL']) && is_array($rss['MEDIA:GROUP']['MEDIA:THUMBNAIL'][1])) {
$thumbnail = $rss['MEDIA:GROUP']['MEDIA:THUMBNAIL'][1];
$data['thumbnail']['filepath'] = $thumbnail['URL'];
$data['thumbnail']['width'] = $thumbnail['WIDTH'];
$data['thumbnail']['height'] = $thumbnail['HEIGHT'];
}
if (is_array($rss['MEDIA:GROUP']['MEDIA:PLAYER']) && is_array($rss['MEDIA:GROUP']['MEDIA:PLAYER'][1])) {
$data['player']['filepath'] = $rss['MEDIA:GROUP']['MEDIA:PLAYER'][1]['URL'];
}
}
if ($data['thumbnail']['filepath'] == '') {
// for whatever reason the thumbnail failed try the old method
// we'll parse it from the description, where it's repeated.
$desc = $rss['ITEM']['DESCRIPTION'][0];
$regex = '@ media, just MRSS, and no size
// so not actually really really necessary or really useful but for completeness
$play = 'http://video.google.'. variable_get('video_cck_google_domain', VIDEO_CCK_GOOGLE_DOMAIN_DEFAULT) .'/googleplayer.swf?docId='. check_plain($item['embed']);
$response = emfield_request_header('google', $play, FALSE, FALSE);
if ($response->code == 200) {
$data['filesize'] = $response->headers['Content-Length'];
}
return $data;
}
function video_cck_google_rss($item, $teaser) {
if ($item['value']) {
if ($item['data']['video_cck_google_data_version'] >= 1000000) {
$data = $item['data'];
}
else {
$data = video_cck_google_data(NULL, $item);
}
return $data;
}
}
function video_cck_google_thumbnail($field, $item, $formatter, $node, $width, $height) {
if ($item['data']['video_cck_google_data_version'] >= 1) {
$data = $item['data'];
}
else {
$data = video_cck_google_data($field, $item);
}
return $data['thumbnail']['filepath'];
return NULL;
}
function video_cck_google_video($embed, $width, $height, $field, $item, $autoplay) {
$output = theme('video_cck_google_flash', $embed, $width, $height, $autoplay);
return $output;
}
function video_cck_google_preview($embed, $width, $height, $field, $item, $autoplay) {
$output = theme('video_cck_google_flash', $embed, $width, $height, $autoplay);
return $output;
}