Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(!function_exists('avia_html5_video_embed'))
- {
- /**
- * Creates HTML 5 output and also prepares flash fallback for a video of choice
- * @return string HTML5 video element
- */
- function avia_html5_video_embed($path, $image = "", $types = array('webm' => 'type="video/webm"', 'mp4' => 'type="video/mp4"', 'ogv' => 'type="video/ogg"'), $attributes)
- {
- preg_match("!^(.+?)(?:\.([^.]+))?$!", $path, $path_split);
- $output = "";
- if(isset($path_split[1]))
- {
- if(!$image && avia_is_200($path_split[1].'.jpg'))
- {
- $image = 'poster="'.$path_split[1].'.jpg"'; //poster image isnt accepted by the player currently, waiting for bugfix
- }
- $autoplay = $attributes['autoplay'] == 1 ? 'autoplay' : '';
- $loop = $attributes['loop'] == 1 ? 'loop' : '';
- $metadata = $attributes['loop'] == 1 ? 'preload="metadata"' : 'preload="auto"';
- $uid = 'player_'.get_the_ID().'_'.mt_rand().'_'.mt_rand();
- $output .= '<video class="avia_video" '.$image.' '.$autoplay.' '.$loop.' '.$metadata.' controls id="'.$uid.'" >';
- foreach ($types as $key => $type)
- {
- if($path_split[2] == $key || avia_is_200($path_split[1].'.'.$key))
- {
- $output .= ' <source src="'.$path_split[1].'.'.$key.'" '.$type.' />';
- }
- }
- $output .= '</video>';
- }
- return $output;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement