diff --git a/video_filter.codecs.inc b/video_filter.codecs.inc
index 8fa6ce4..99af3be 100644
--- a/video_filter.codecs.inc
+++ b/video_filter.codecs.inc
@@ -7,6 +7,7 @@ function video_filter_codec_info() {
'name' => t('YouTube'),
'sample_url' => 'http://www.youtube.com/watch?v=uN1qUeId',
'callback' => 'video_filter_youtube',
+ 'html5_callback' => 'video_filter_youtube_html5',
'regexp' => '/youtube\.com\/watch\?v=([a-z0-9\-_]+)/i',
'ratio' => 16 / 9,
'control_bar_height' => 25,
@@ -40,6 +41,7 @@ function video_filter_codec_info() {
'name' => t('Vimeo'),
'sample_url' => 'http://www.vimeo.com/123456',
'callback' => 'video_filter_vimeo',
+ 'html5_callback' => 'video_filter_vimeo_html5',
'regexp' => '/vimeo\.com\/([0-9]+)/',
'ratio' => 16 / 9,
'control_bar_height' => 0,
@@ -170,11 +172,27 @@ function video_filter_codec_info() {
}
function video_filter_youtube($video) {
- $video['source'] = 'http://www.youtube.com/v/'.$video['codec']['matches'][1].($video['autoplay'] ? '&autoplay=1' : '').'&fs=1'.($video['related'] ? '' : '&rel=0');
+ $attributes = array(
+ 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
+ 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
+ );
+
+ $video['source'] = 'http://www.youtube.com/v/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes);
return video_filter_flash($video);
}
+function video_filter_youtube_html5($video) {
+ $attributes = array(
+ 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
+ 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
+ );
+ $url = $video['codec']['matches'][1] . '?' . implode('&', $attributes);
+ $html = '';
+
+ return $html;
+}
+
function video_filter_google($video) {
$video['source'] = 'http://video.google.com/googleplayer.swf?docId='.$video['codec']['matches'][1];
@@ -199,6 +217,12 @@ function video_filter_vimeo($video) {
return video_filter_flash($video);
}
+function video_filter_vimeo_html5($video) {
+ $html = '';
+
+ return $html;
+}
+
function video_filter_flickr_slideshows($video) {
$slideshow_player_url = 'http://www.flickr.com/apps/slideshow/show.swf?v=67348';
$video['source'] = $slideshow_player_url . ($video['autoplay'] ? '&autoplay=1' : '');
diff --git a/video_filter.module b/video_filter.module
index 2768885..6644d8f 100644
--- a/video_filter.module
+++ b/video_filter.module
@@ -389,8 +389,8 @@ function video_filter_process($text, $format = -1) {
}
// Fall back to defaults.
elseif (!isset($video['height']) && !isset($video['width'])) {
- $video['width'] = variable_get('video_filter_width_'.$format, 400);
- $video['height'] = variable_get('video_filter_height_'.$format, 400);
+ $video['width'] = variable_get('video_filter_width_'.$format, 400) != '' ? variable_get('video_filter_width_'.$format, 400) : 400;
+ $video['height'] = variable_get('video_filter_height_'.$format, 400) != '' ? variable_get('video_filter_height_'.$format, 400) : 400;
}
// Default value for control bar height
@@ -414,7 +414,10 @@ function video_filter_process($text, $format = -1) {
$video['autoplay'] = (bool) $video['autoplay'];
$video['align'] = (isset($video['align']) && in_array($video['align'], array('left', 'right', 'center'))) ? $video['align'] : NULL;
- if (is_callable($video['codec']['callback'], FALSE)) {
+ if (variable_get('video_filter_html5_'.$format, 1) == 1 && is_callable($video['codec']['html5_callback'], FALSE)) {
+ $replacement = call_user_func($video['codec']['html5_callback'], $video);
+ }
+ elseif (is_callable($video['codec']['callback'], FALSE)) {
$replacement = call_user_func($video['codec']['callback'], $video);
}
else {
@@ -472,6 +475,16 @@ function video_filter_settings($format) {
1 => t('Yes'),
),
);
+ $form['video_filter']['video_filter_html5_'.$format] = array(
+ '#type' => 'radios',
+ '#title' => t('Use HTML5'),
+ '#description' => t('Use HTML5 if the codec provides it. Makes your videos more device agnostic.'),
+ '#default_value' => variable_get('video_filter_html5_'.$format, 1),
+ '#options' => array(
+ 0 => t('No'),
+ 1 => t('Yes'),
+ ),
+ );
return $form;
}