emvideo_ina.module in Asset 7
Emvideo ina module.
File
modules/emvideo/modules/emvideo_ina/emvideo_ina.moduleView source
<?php
/**
* @file
* Emvideo ina module.
*/
/**
* Implements hook_emvideo_parse().
*/
function emvideo_ina_emvideo_parse($data) {
$video_id = $id_user = $hashcode = NULL;
$ret = FALSE;
if (preg_match('@/video/ticket/([a-zA-Z0-9\\/]*)@', $data, $matches)) {
$embed = explode('/', $matches[1]);
$video_id = $embed[0];
$id_user = $embed[1];
$hashcode = $embed[2];
$ret = array(
'source' => "id_notice/{$video_id}/id_utilisateur/{$id_user}/hash/{$hashcode}",
'provider' => 'ina',
);
}
elseif (preg_match('@http://www.ina.fr(?:.*?)/video/([^/]*)@', $data, $matches)) {
$video_id = $matches[1];
$id_user = variable_get('emvideo_ina_id_user');
$hashcode = variable_get('emvideo_ina_hashcode');
$ret = array(
'source' => "id_notice/{$video_id}/id_utilisateur/{$id_user}/hash/{$hashcode}",
'provider' => 'ina',
);
}
elseif (preg_match('@<iframe(?:.*?)src=\'(.*?)\'@i', $data, $matches)) {
$source = $matches[1];
$matches = array();
$ret = array(
'source' => $source,
'provider' => 'ina',
);
if (preg_match('@http://player\\.ina\\.fr/player/embed/([0-9]+)/@i', $source, $matches)) {
$video_id = $matches[1];
}
}
elseif (preg_match('@<embed(?:.*?)src=\'(.*?)\'@i', $data, $matches)) {
$source = $matches[1];
$matches = array();
$ret = array(
'source' => $source,
'provider' => 'ina',
);
if (preg_match('@http://player\\.ina\\.fr/player/ticket/([0-9]+)/@i', $source, $matches)) {
$video_id = $matches[1];
}
}
if ($video_id) {
$ret['snapshot'] = 'http://www.ina.fr/images_v2/320x240/' . $video_id . '.jpeg';
}
return $ret;
}
/**
* Implements hook_emvideo_emcode().
*/
function emvideo_ina_emvideo_emcode($params) {
$output = FALSE;
if (isset($params['provider']) && $params['provider'] == 'ina') {
$width = $params['width'];
$height = $params['height'];
$source = $params['source'];
if (strpos($source, 'http://player.ina.fr/player/embed/') === 0) {
// IFrame URL contain sized, so we need to substitute them.
$source = explode('/', $source);
$tmp_id_1 = array_pop($source);
$tmp_id_2 = array_pop($source);
// Skip old width and height.
array_pop($source);
array_pop($source);
$source[] = $width;
$source[] = $height;
$source[] = $tmp_id_2;
$source[] = $tmp_id_1;
$source = implode('/', $source);
$attrs = array(
'width' => $width,
'height' => $height,
'frameborder' => '0',
'marginheight' => '0',
'marginwidth' => '0',
'scrolling' => 'no',
'src' => $source,
);
$output = '<iframe' . drupal_attributes($attrs) . '></iframe>';
}
elseif (strpos($source, 'http://player.ina.fr/player/ticket/') === 0) {
$output = "<object width='{$width}' height='{$height}' >\n <param name='movie' value='{$source}' />\n <param name='allowScriptAccess' value='always' />\n <param name='allowFullScreen' value='true' />\n <param name='bgcolor' value='#000000' />\n <embed src='{$source}' width='{$width}' height='{$height}' allowScriptAccess='always' allowFullScreen='true' type='application/x-shockwave-flash'>\n </embed>\n </object>";
}
else {
$embed = explode('/', $source);
$id_notice = $embed[1];
$id_user = $embed[3];
$hashcode = $embed[5];
$output = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="Visionneuse" width="' . $width . '" height="' . $height . '"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="http://www.ina.fr/video/ticket/' . $id_notice . '/' . $id_user . '/' . $hashcode . '" />
<param name="pluginspage" value="http://www.macromedia.com/go/getflashplayer">
<param name="align" value="middle">
<param name="quality" value="high" />
<param name="scale" value="showall">
<param name="wmode" value="transparent">
<param name="menu" value="true">
<param name="devicefont" value="false">
<param name="bgcolor" value="#FFFFFF" />
<param name="allowScriptAccess" value="always" />
<param name="allowFullScreen" value="true" />
<param name="flashvars" value="config=http://www.ina.fr/player/configurationEmbed&type_media=video">
<embed src="http://www.ina.fr/video/ticket/' . $id_notice . '/' . $id_user . '/' . $hashcode . '" quality="high" bgcolor="#FFFFFF"
width="' . $width . '" height="' . $height . '" name="Viewer" align="middle"
quality="high"
wmode="transparent"
allowScriptAccess="always"
allowFullScreen="true"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer"
flashvars="config=http://www.ina.fr/player/configurationEmbed&type_media=video">
</embed>
</object>';
}
}
return $output;
}
/**
* Implements hook_menu().
*/
function emvideo_ina_menu() {
return array(
'admin/config/media/emvideo_ina' => array(
'title' => 'Embedded video INA.fr',
'description' => 'INA.fr video embedding settings',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'emvideo_ina_settings_form',
),
'access arguments' => array(
'administer site configuration',
),
),
);
}
/**
* Implements hook_field_settings_form().
*/
function emvideo_ina_settings_form($form, &$form_state) {
$form['emvideo_ina_id_user'] = array(
'#type' => 'textfield',
'#title' => t('INA User ID'),
'#default_value' => variable_get('emvideo_ina_id_user'),
);
$form['emvideo_ina_hashcode'] = array(
'#type' => 'textfield',
'#title' => t('INA Hash code'),
'#default_value' => variable_get('emvideo_ina_hashcode'),
);
return system_settings_form($form);
}
Functions
Name![]() |
Description |
---|---|
emvideo_ina_emvideo_emcode | Implements hook_emvideo_emcode(). |
emvideo_ina_emvideo_parse | Implements hook_emvideo_parse(). |
emvideo_ina_menu | Implements hook_menu(). |
emvideo_ina_settings_form | Implements hook_field_settings_form(). |