function video_filter_youtube_html5 in Video Filter 7.3
Same name and namespace in other branches
- 6.3 video_filter.codecs.inc \video_filter_youtube_html5()
HTML5 callback for YouTube codec.
See also
1 string reference to 'video_filter_youtube_html5'
- video_filter_codec_info in ./
video_filter.codecs.inc - Implements hook_codec_info().
File
- ./
video_filter.codecs.inc, line 1061 - This file contains all codecs provided by Video Filter.
Code
function video_filter_youtube_html5($video) {
$attributes = array(
'modestbranding' => !empty($video['modestbranding']) ? 'modestbranding=1' : 'modestbranding=0',
'html5' => 'html5=1',
'rel' => $video['related'] ? 'rel=1' : 'rel=0',
'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
'wmode' => 'wmode=opaque',
'loop' => !empty($video['loop']) ? 'loop=1' : 'loop=0',
'controls' => !empty($video['controls']) ? 'controls=1' : (!isset($video['controls']) ? 'controls=1' : 'controls=0'),
'autohide' => !empty($video['autohide']) ? 'autohide=1' : 'autohide=0',
'showinfo' => !empty($video['showinfo']) ? 'showinfo=1' : 'showinfo=0',
'theme' => !empty($video['theme']) ? 'theme=' . $video['theme'] : 'theme=dark',
'color' => !empty($video['color']) ? 'color=' . $video['color'] : 'color=red',
'enablejsapi' => !empty($video['enablejsapi']) ? 'enablejsapi=' . (int) $video['enablejsapi'] : 'enablejsapi=0',
);
if (!empty($video['loop'])) {
$attributes['playlist'] = 'playlist=' . $video['codec']['matches'][1];
}
if (preg_match('/[\\?|&]t=((?<minutes>\\d+m)?(?<seconds>\\d+s?)?)/', $video['source'], $matches)) {
$attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches['minutes']) * 60 + preg_replace("/[^0-9]/", "", $matches['seconds']));
}
if (!empty($video['start'])) {
if (preg_match('/((?<minutes>\\d+m)?(?<seconds>\\d+s?)?)/', $video['start'], $matches)) {
$attributes['start'] = 'start=' . (preg_replace("/[^0-9]/", "", $matches['minutes']) * 60 + preg_replace("/[^0-9]/", "", $matches['seconds']));
}
}
$video['source'] = '//www.youtube.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&', $attributes);
return video_filter_iframe($video);
}