Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
117 lines (106 sloc) 3.13 KB
<?php
/**
* @file media_23video/media_23video.module
* Embedded Video Field provider file for 23 Video.
*/
/* ***************************************** */
/* INCLUDES */
/* ***************************************** */
// A registry of variable_get defaults.
include_once('includes/media_23video.variables.inc');
/**
* Implementation of hook_menu().
*/
function media_23video_menu() {
return array(
'admin/settings/media_23video' => array(
'title' => 'Media: 23 Video',
'description' => 'Administer the Media: 23 Video module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('media_23video_settings'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/media_23video.admin.inc',
),
);
}
/**
* Implementation of hook_emfield_providers().
*/
function media_23video_emfield_providers($module, $provider = NULL) {
// We know this module only includes the main provider file, avoid needless
// PHP warnings.
if ($module == 'emvideo' && (!isset($provider) || ($provider == '23video'))) {
static $path;
// Cache the result for later.
if (!isset($path)) {
$found = drupal_system_listing("$provider\.inc$", drupal_get_path('module', 'media_23video') ."/includes/providers/$module", 'name', 0);
if (is_array($found) && !empty($found)) {
$path = $found;
}
}
return $path;
}
}
/**
* Return the direct URL to this video.
*
* @param string $video_code
* The 23 Video video id.
*
* @return string
* The direct URL to the video in question.
*/
function media_23video_video_url($video_code) {
return url('http://www.23video.com/'. $video_code);
}
/**
* The URL to the thumbnail video still for the media.
*
* @param $string $video_code
* The 23 Video video ID.
*
* @return string
* The URL to the thumbnail.
*/
function media_23video_thumbnail_url($video_code) {
$data = media_23video_data($video_code);
if (isset($data['thumbnail_large'])) {
return $data['thumbnail_large'];
}
else if (isset($data['thumbnail_medium'])) {
return $data['thumbnail_medium'];
}
if (isset($data['thumbnail_small'])) {
return $data['thumbnail_small'];
}
// Fallback to oembed.
$xml = emfield_request_xml('23video', 'http://23video.com/api/oembed.xml?url=http%3A//23video.com/'. $video_code, array(), TRUE, FALSE, $video_code);
return url($xml['OEMBED']['THUMBNAIL_URL'][0]);
}
/**
* Return an array of external metadata provided by 23 Video.
*
* @param string $video_code
* The 23 Video video ID.
*
* @return array
* The metadata associated with the video.
*/
function media_23video_data($video_code) {
$url = url('http://23video.com/api/v2/video/'. $video_code .'.php');
$xml = emfield_request_xml('23video', $url, array(), TRUE, FALSE, $video_code, TRUE);
return array_pop($xml);
}
/**
* Return the duration of a 23 Video video.
*
* @param string $video_code
* The 23 Video video ID.
*
* @return integer
* The duration in seconds.
*/
function media_23video_duration($video_code) {
$data = media_23video_data($video_code);
return $data['duration'];
}