Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( !class_exists( 'avia_slideshow_video_helper' ) )
- {
- class avia_slideshow_video_helper
- {
- static function set_video_slide($video_url, $service = false, $meta = false)
- {
- $video = "";
- if(empty($service)) $service = self::which_video_service($video_url);
- $uid = 'player_'.get_the_ID().'_'.mt_rand().'_'.mt_rand();
- $controls = empty($meta['video_controls']) ? 1 : 0;
- $loop = empty($meta['video_loop']) ? 0 : 1;
- $autoplay = empty($meta['video_autoplay']) ? true : false;
- switch( $service )
- {
- case "html5": $video = "<div class='av-click-overlay'></div>".avia_html5_video_embed($video_url, $image = "", $types = array('webm' => 'type="video/webm"', 'mp4' => 'type="video/mp4"', 'ogv' => 'type="video/ogg"'), $autoplay); break;
- case "iframe":$video = $video_url; break;
- case "youtube":
- $explode_at = strpos($video_url, 'youtu.be/') !== false ? "/" : "v=";
- $video_url = explode($explode_at, trim($video_url));
- $video_url = end($video_url);
- $video_id = $video_url;
- //if parameters are appended make sure to create the correct video id
- if (strpos($video_url,'?') !== false || strpos($video_url,'?') !== false)
- {
- preg_match('!(.+)[&?]!',$video_url, $video_id);
- $video_id = isset($video_id[1]) ? $video_id[1] : $video_id[0];
- }
- $video_data = apply_filters( 'avf_youtube_video_data', array(
- 'autoplay' => 0,
- 'videoid' => $video_id,
- 'hd' => 1,
- 'rel' => 0,
- 'wmode' => 'opaque',
- 'playlist' => $uid,
- 'loop' => 0,
- 'version' => 3,
- 'autohide' => 1,
- 'color' => 'white',
- 'controls' => $controls,
- 'showinfo' => 0,
- 'iv_load_policy'=> 3
- ));
- $data = AviaHelper::create_data_string($video_data);
- $video = "<div class='av-click-overlay'></div><div class='mejs-mediaelement'><div height='1600' width='900' class='av_youtube_frame' id='{$uid}' {$data}></div></div>";
- break;
- case "vimeo":
- $color = ltrim( avia_get_option('colorset-main_color-primary'), '#');
- $autopause = empty($meta['video_section_bg']) ? 1 : 0; //pause if another vimeo video plays?
- $video_url = explode('/', trim($video_url));
- $video_url = end($video_url);
- $video_url = esc_url(add_query_arg(
- array(
- 'portrait' => 0,
- 'byline' => 0,
- 'title' => 0,
- 'badge' => 0,
- 'loop' => $loop,
- 'autopause' => $autopause,
- 'api' => 1,
- 'rel' => 0,
- 'player_id' => $uid,
- 'color' => $color
- ),
- '//player.vimeo.com/video/'.$video_url
- ));
- $video_url = apply_filters( 'avf_vimeo_video_url' , $video_url);
- $video = "<div class='av-click-overlay'></div><div class='mejs-mediaelement'><iframe src='{$video_url}' height='1600' width='900' frameborder='' class='av_vimeo_frame' id='{$uid}'></iframe></div>";
- break;
- }
- return $video;
- }
- //get the video service based on the url string fo the video
- static function which_video_service($video_url)
- {
- $service = "";
- if(avia_backend_is_file($video_url, 'html5video'))
- {
- $service = "html5";
- }
- else if(strpos($video_url,'<iframe') !== false)
- {
- $service = "iframe";
- }
- else
- {
- if(strpos($video_url, 'youtube.com/watch') !== false || strpos($video_url, 'youtu.be/') !== false)
- {
- $service = "youtube";
- }
- else if(strpos($video_url, 'vimeo.com') !== false)
- {
- $service = "vimeo";
- }
- }
- return $service;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment