isset( $_GET['uid'] ) ? sanitize_text_field( $_GET['uid'] ) : 0, 'post_id' => $post_id, 'post_type' => $post_type, 'is_trailer' => $is_trailer, 'cc_load_policy' => isset( $_GET['cc_load_policy'] ) ? (int) $_GET['cc_load_policy'] : (int) $player_settings['cc_load_policy'], 'hotkeys' => isset( $player_settings['hotkeys'] ) && ! empty( $player_settings['hotkeys'] ) ? 1 : 0, 'statistics' => isset( $general_settings['statistics'] ) ? (int) $general_settings['statistics'] : 1, 'player' => array( 'controlBar' => array(), 'liveui' => true, 'textTrackSettings' => false, 'playbackRates' => array( 0.5, 0.75, 1, 1.5, 2 ), 'techCanOverridePoster' => true, 'suppressNotSupportedError' => true ), 'i18n' => array( 'stream_not_found' => __( 'This stream is currently not live. Please check back or refresh your page.', 'all-in-one-video-gallery' ) ) ); $autoadvance = isset( $_GET['autoadvance'] ) ? (int) $_GET['autoadvance'] : 0; if ( $autoadvance ) { $settings['autoadvance'] = 1; } // Video Sources $sources = array(); $allowed_types = array( 'mp4', 'webm', 'ogv', 'hls', 'dash', 'youtube', 'vimeo' ); if ( ! empty( $post_meta ) ) { $type = $post_meta['type'][0]; switch ( $type ) { case 'default': $types = array( 'mp4', 'webm', 'ogv' ); foreach ( $types as $type ) { if ( ! empty( $post_meta[ $type ][0] ) ) { $ext = $type; $label = ''; if ( 'mp4' == $type ) { $ext = aiovg_get_file_ext( $post_meta[ $type ][0] ); if ( ! in_array( $ext, array( 'webm', 'ogv' ) ) ) { $ext = 'mp4'; } if ( ! empty( $post_meta['quality_level'][0] ) ) { $label = $post_meta['quality_level'][0]; } } $sources[ $type ] = array( 'type' => "video/{$ext}", 'src' => $post_meta[ $type ][0] ); if ( ! empty( $label ) ) { $sources[ $type ]['label'] = $label; } } } if ( ! empty( $post_meta['sources'][0] ) ) { $_sources = maybe_unserialize( $post_meta['sources'][0] ); foreach ( $_sources as $source ) { if ( ! empty( $source['quality'] ) && ! empty( $source['src'] ) ) { $ext = aiovg_get_file_ext( $source['src'] ); if ( ! in_array( $ext, array( 'webm', 'ogv' ) ) ) { $ext = 'mp4'; } $label = $source['quality']; $sources[ $label ] = array( 'type' => "video/{$ext}", 'src' => $source['src'], 'label' => $label ); } } } break; case 'adaptive': $hls = isset( $post_meta['hls'] ) ? $post_meta['hls'][0] : ''; if ( ! empty( $hls ) ) { $sources['hls'] = array( 'type' => 'application/x-mpegurl', 'src' => $hls ); } $dash = isset( $post_meta['dash'] ) ? $post_meta['dash'][0] : ''; if ( ! empty( $dash ) ) { $sources['dash'] = array( 'type' => 'application/dash+xml', 'src' => $dash ); } break; default: if ( in_array( $type, $allowed_types ) && ! empty( $post_meta[ $type ][0] ) ) { $src = $post_meta[ $type ][0]; $sources[ $type ] = array( 'type' => "video/{$type}", 'src' => $src ); } } } else { foreach ( $allowed_types as $type ) { if ( isset( $_GET[ $type ] ) && ! empty( $_GET[ $type ] ) ) { switch ( $type ) { case 'hls': $mime_type = 'application/x-mpegurl'; break; case 'dash': $mime_type = 'application/dash+xml'; break; default: $mime_type = "video/{$type}"; } $src = aiovg_base64_decode( $_GET[ $type ] ); $src = aiovg_sanitize_url( aiovg_make_url_absolute( $src ) ); $sources[ $type ] = array( 'type' => $mime_type, 'src' => $src ); } } } $sources = apply_filters( 'aiovg_video_sources', $sources, $settings ); // Backward compatibility to 3.3.0 $sources = apply_filters( 'aiovg_iframe_videojs_player_sources', $sources, $settings ); // Video Tracks if ( 1 == $settings['cc_load_policy'] ) { $has_tracks = 1; } else { $has_tracks = isset( $_GET['tracks'] ) ? (int) $_GET['tracks'] : isset( $player_settings['controls']['tracks'] ); } $tracks = array(); if ( $has_tracks && ! empty( $post_meta['track'] ) ) { foreach ( $post_meta['track'] as $track ) { $tracks[] = maybe_unserialize( $track ); } $has_srt_found = 0; foreach ( $tracks as $index => $track ) { $ext = pathinfo( $track['src'], PATHINFO_EXTENSION ); if ( 'srt' == strtolower( $ext ) ) { $has_srt_found = 1; break; } } if ( $has_srt_found ) { $settings['tracks'] = $tracks; $tracks = array(); } } $tracks = apply_filters( 'aiovg_video_tracks', $tracks ); // Backward compatibility to 3.3.0 $tracks = apply_filters( 'aiovg_iframe_videojs_player_tracks', $tracks ); // Video Chapters $has_chapters = isset( $_GET['chapters'] ) ? (int) $_GET['chapters'] : isset( $player_settings['controls']['chapters'] ); if ( $has_chapters && 'aiovg_videos' == $post_type ) { $post = get_post( $post_id ); $chapters = aiovg_extract_chapters_from_string( $post->post_content ); if ( ! empty( $post_meta['chapter'] ) ) { foreach ( $post_meta['chapter'] as $chapter ) { $chapter = maybe_unserialize( $chapter ); $seconds = aiovg_convert_time_to_seconds( $chapter['time'] ); $chapters[ $seconds ] = array( 'time' => $seconds, 'label' => sanitize_text_field( $chapter['label'] ) ); } } if ( ! empty( $chapters ) ) { $settings['chapters'] = array_values( $chapters ); } } // Video Attributes $attributes = array( 'id' => 'player', 'class' => 'video-js vjs-fill', 'style' => 'width: 100%; height: 100%;', 'controls' => '', 'preload' => esc_attr( $player_settings['preload'] ) ); $theme = ( isset( $player_settings['theme'] ) && 'custom' == $player_settings['theme'] ) ? 'custom' : 'default'; $attributes['class'] .= ' vjs-theme-' . $theme; $autoplay = isset( $_GET['autoplay'] ) ? (int) $_GET['autoplay'] : (int) $player_settings['autoplay']; if ( $autoplay ) { $settings['player']['autoplay'] = true; } $loop = isset( $_GET['loop'] ) ? (int) $_GET['loop'] : (int) $player_settings['loop']; if ( $loop ) { $attributes['loop'] = ''; } $muted = isset( $_GET['muted'] ) ? (int) $_GET['muted'] : (int) $player_settings['muted']; if ( $muted ) { $attributes['muted'] = ''; } $playsinline = ! empty( $player_settings['playsinline'] ) ? 1 : 0; if ( $playsinline ) { $attributes['playsinline'] = ''; } $poster = ''; if ( isset( $_GET['poster'] ) ) { $poster = aiovg_base64_decode( $_GET['poster'] ); } elseif ( ! empty( $post_meta ) ) { $image_data = aiovg_get_image( $post_id, 'large' ); $poster = $image_data['src']; } if ( ! empty( $poster) ) { $attributes['poster'] = esc_url( aiovg_make_url_absolute( $poster ) ); } if ( ! empty( $brand_settings ) && ! empty( $brand_settings['copyright_text'] ) ) { $attributes['controlsList'] = 'nodownload'; $attributes['oncontextmenu'] = 'return false;'; } // Player Settings $controls = array( 'playpause' => 'PlayToggle', 'current' => 'CurrentTimeDisplay', 'progress' => 'ProgressControl', 'duration' => 'DurationDisplay', 'spacer' => 'CustomControlSpacer', 'tracks' => 'CaptionsButton', 'speed' => 'PlaybackRateMenuButton', 'quality' => 'QualitySelector', 'volume' => 'VolumePanel', 'pip' => 'PictureInPictureToggle', 'fullscreen' => 'FullscreenToggle' ); foreach ( $controls as $index => $control ) { $enabled = isset( $_GET[ $index ] ) ? (int) $_GET[ $index ] : isset( $player_settings['controls'][ $index ] ); if ( 'spacer' == $index ) { $enabled = 1; } if ( $enabled && 'pip' == $index ) { if ( isset( $sources['youtube'] ) || isset( $sources['vimeo'] ) ) { $enabled = 0; } } if ( ! $enabled ) { unset( $controls[ $index ] ); } } if ( isset( $sources['hls'] ) || isset( $sources['dash'] ) ) { if ( isset( $controls['progress'] ) ) { $controls = aiovg_insert_array_after( 'progress', $controls, array( 'liveui' => 'SeekToLive' )); } } if ( isset( $controls['current'] ) && isset( $controls['duration'] ) ) { if ( 'custom' == $theme || ! isset( $controls['progress'] ) ) { $controls = aiovg_insert_array_after( 'current', $controls, array( 'timedivider' => 'TimeDivider' )); } } if ( isset( $controls['tracks'] ) ) { $controls = aiovg_insert_array_after( 'tracks', $controls, array( 'audio' => 'AudioTrackButton' )); } $settings['player']['controlBar']['children'] = array_values( $controls ); if ( ! isset( $controls['progress'] ) ) { $attributes['class'] .= ' vjs-no-progress-control'; } if ( empty( $controls ) || ( 1 == count( $controls ) && isset( $controls['spacer'] ) ) ) { $attributes['class'] .= ' vjs-no-control-bar'; } $attributes = apply_filters( 'aiovg_video_attributes', $attributes ); // Backward compatibility to 3.3.0 $attributes = apply_filters( 'aiovg_iframe_videojs_player_attributes', $attributes ); // YouTube if ( isset( $sources['youtube'] ) ) { $settings['player']['techOrder'] = array( 'youtube' ); $settings['player']['youtube'] = array( 'iv_load_policy' => 3, 'playsinline' => $playsinline ); parse_str( $sources['youtube']['src'], $queries ); if ( isset( $queries['start'] ) ) { $settings['start'] = (int) $queries['start']; } if ( isset( $queries['t'] ) ) { $settings['start'] = (int) $queries['t']; } if ( isset( $queries['end'] ) ) { $settings['end'] = (int) $queries['end']; } // Hide YouTube Logo if ( ! empty( $player_settings['hide_youtube_logo'] ) ) { $attributes['class'] .= ' vjs-hide-youtube-logo'; } } // Vimeo if ( isset( $sources['vimeo'] ) ) { $settings['player']['techOrder'] = array( 'vimeo2' ); $settings['player']['vimeo2'] = array( 'playsinline' => $playsinline ); if ( strpos( $sources['vimeo']['src'], 'player.vimeo.com' ) !== false ) { $video_id = aiovg_get_vimeo_id_from_url( $sources['vimeo']['src'] ); $sources['vimeo']['src'] = 'https://vimeo.com/' . $video_id; } } // Share $has_share = isset( $_GET['share'] ) ? (int) $_GET['share'] : isset( $player_settings['controls']['share'] ); if ( $has_share ) { $socialshare_settings = aiovg_get_option( 'aiovg_socialshare_settings' ); $share_url = $post_url; $share_url_encoded = rawurlencode( $share_url ); $share_title = rawurlencode( $post_title ); $share_image = isset( $attributes['poster'] ) ? $attributes['poster'] : ''; $share_buttons = array(); if ( isset( $socialshare_settings['services']['facebook'] ) ) { $share_buttons[] = array( 'service' => 'facebook', 'url' => "https://www.facebook.com/sharer/sharer.php?u={$share_url_encoded}", 'icon' => 'aiovg-icon-facebook', 'text' => __( 'Facebook', 'all-in-one-video-gallery' ) ); } if ( isset( $socialshare_settings['services']['twitter'] ) ) { $share_buttons[] = array( 'service' => 'twitter', 'url' => "https://twitter.com/intent/tweet?text={$share_title}&url={$share_url_encoded}", 'icon' => 'aiovg-icon-twitter', 'text' => __( 'Twitter', 'all-in-one-video-gallery' ) ); } if ( isset( $socialshare_settings['services']['linkedin'] ) ) { $share_buttons[] = array( 'service' => 'linkedin', 'url' => "https://www.linkedin.com/shareArticle?url={$share_url_encoded}&title={$share_title}", 'icon' => 'aiovg-icon-linkedin', 'text' => __( 'Linkedin', 'all-in-one-video-gallery' ) ); } if ( isset( $socialshare_settings['services']['pinterest'] ) ) { $pinterest_url = "https://pinterest.com/pin/create/button/?url={$share_url_encoded}&description={$share_title}"; if ( ! empty( $share_image ) ) { $pinterest_url .= "&media={$share_image}"; } $share_buttons[] = array( 'service' => 'pinterest', 'url' => $pinterest_url, 'icon' => 'aiovg-icon-pinterest', 'text' => __( 'Pinterest', 'all-in-one-video-gallery' ) ); } if ( isset( $socialshare_settings['services']['tumblr'] ) ) { $tumblr_url = "https://www.tumblr.com/share/link?url={$share_url_encoded}&name={$share_title}"; $share_description = aiovg_get_excerpt( $post_id, 160, '', false ); if ( ! empty( $share_description ) ) { $share_description = rawurlencode( $share_description ); $tumblr_url .= "&description={$share_description}"; } $share_buttons[] = array( 'service' => 'tumblr', 'url' => $tumblr_url, 'icon' => 'aiovg-icon-tumblr', 'text' => __( 'Tumblr', 'all-in-one-video-gallery' ) ); } if ( isset( $socialshare_settings['services']['whatsapp'] ) ) { if ( wp_is_mobile() ) { $whatsapp_url = "whatsapp://send?text={$share_title} {$share_url_encoded}"; } else { $whatsapp_url = "https://api.whatsapp.com/send?text={$share_title}%20{$share_url_encoded}"; } $share_buttons[] = array( 'service' => 'whatsapp', 'url' => $whatsapp_url, 'icon' => 'aiovg-icon-whatsapp', 'text' => __( 'WhatsApp', 'all-in-one-video-gallery' ) ); } if ( isset( $socialshare_settings['services']['email'] ) ) { $email_subject = sprintf( __( 'Check out the "%s"', 'all-in-one-video-gallery' ), $share_title ); $email_body = sprintf( __( 'Check out the "%s" at %s', 'all-in-one-video-gallery' ), $share_title, $share_url ); $email_url = "mailto:?subject={$email_subject}&body={$email_body}"; $share_buttons[] = array( 'service' => 'email', 'url' => $email_url, 'icon' => 'aiovg-icon-email', 'text' => __( 'Email', 'all-in-one-video-gallery' ) ); } $share_buttons = apply_filters( 'aiovg_player_socialshare_buttons', $share_buttons ); if ( ! empty( $share_buttons ) ) { $settings['share'] = 1; } } // Embed $has_embed = isset( $_GET['embed'] ) ? (int) $_GET['embed'] : isset( $player_settings['controls']['embed'] ); if ( $has_embed ) { $protocol = ( ( ! empty( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ) || $_SERVER['SERVER_PORT'] == 443 ) ? 'https://' : 'http://'; $current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $current_url = aiovg_remove_query_arg( array( 'uid', 'autoadvance' ), $current_url ); $embed_code = sprintf( '
', ( isset( $_GET['ratio'] ) ? (float) $_GET['ratio'] : (float) $player_settings['ratio'] ) . '%', esc_url( $current_url ), esc_attr( $post_title ) ); $settings['embed'] = 1; } // Download if ( isset( $sources['mp4'] ) ) { $has_download = isset( $player_settings['controls']['download'] ); $download_url = ''; if ( ! empty( $post_meta ) ) { if ( isset( $post_meta['download'] ) && empty( $post_meta['download'][0] ) ) { $has_download = 0; } $download_url = home_url( '?vdl=' . $post_id ); } if ( isset( $_GET['download'] ) ) { $has_download = (int) $_GET['download']; } if ( $has_download ) { if ( empty( $download_url ) ) { $download_url = home_url( '?vdl=' . aiovg_get_temporary_file_download_id( $sources['mp4']['src'] ) ); } $settings['download'] = array( 'url' => esc_url( $download_url ) ); } } // Logo if ( ! empty( $brand_settings ) ) { $has_logo = ! empty( $brand_settings['logo_image'] ) ? (int) $brand_settings['show_logo'] : 0; if ( $has_logo ) { $settings['logo'] = array( 'image' => esc_url( aiovg_make_url_absolute( $brand_settings['logo_image'] ) ), 'link' => ! empty( $brand_settings['logo_link'] ) ? esc_url( $brand_settings['logo_link'] ) : 'javascript:void(0)', 'position' => sanitize_text_field( $brand_settings['logo_position'] ), 'margin' => ! empty( $brand_settings['logo_margin'] ) ? (int) $brand_settings['logo_margin'] : 15 ); } $has_contextmenu = ! empty( $brand_settings['copyright_text'] ) ? 1 : 0; if ( $has_contextmenu ) { $settings['contextmenu'] = array( 'content' => wp_strip_all_tags( apply_filters( 'aiovg_translate_strings', $brand_settings['copyright_text'], 'copyright_text' ) ) ); } } // Trailer if ( ! empty( $is_trailer ) ) { $player_overlay_link = isset( $trailer_settings['player_overlay_link'] ) ? $trailer_settings['player_overlay_link'] : ''; $player_overlay_link = apply_filters( 'aiovg_player_overlay_link', $player_overlay_link, $post_id ); $player_overlay_text = isset( $trailer_settings['player_overlay_text'] ) ? $trailer_settings['player_overlay_text'] : ''; if ( empty( $player_overlay_text ) ) { $player_overlay_text = ! empty( $player_overlay_link ) ? __( 'Watch Full Video', 'all-in-one-video-gallery' ) : __( 'Trailer', 'all-in-one-video-gallery' ); } $player_overlay_text = apply_filters( 'aiovg_player_overlay_text', $player_overlay_text, $post_id ); $settings['trailer'] = array( 'label' => wp_strip_all_tags( $player_overlay_text ), 'url' => esc_url( $player_overlay_link ) ); } // Email Capture. if ( ! isset( $_GET['nocapture'] ) ) { if ( ! empty( $email_capture_settings['enable_email_capture'] ) && ! is_user_logged_in() && ! isset( $_COOKIE['aiovg_email_captured'] ) ) { $show_email_capture = 1; if ( 'aiovg_videos' == $post_type && isset( $post_meta['email_capture'] ) ) { $show_email_capture = (int) $post_meta['email_capture'][0]; } if ( isset( $_GET['email_capture'] ) ) { $show_email_capture = (int) $_GET['email_capture']; } if ( $show_email_capture === -1 ) { // Global $show_email_capture = 1; } if ( ! empty( $show_email_capture ) ) { $mid_roll = ! empty( $email_capture_settings['mid_roll'] ) ? (int) $email_capture_settings['mid_roll'] : 0; $post_roll = ! empty( $email_capture_settings['post_roll'] ) ? 1 : 0; $header_text = ! empty( $email_capture_settings['header_text'] ) ? $email_capture_settings['header_text'] : __( 'Enter your email to continue watching', 'all-in-one-video-gallery' ); $footer_text = ! empty( $email_capture_settings['footer_text'] ) ? $email_capture_settings['footer_text'] : ''; $button_label = ! empty( $email_capture_settings['button_label'] ) ? $email_capture_settings['button_label'] : __( 'Submit', 'all-in-one-video-gallery' ); $skip_text = ! empty( $email_capture_settings['skip_text'] ) ? $email_capture_settings['skip_text'] : __( 'Skip', 'all-in-one-video-gallery' ); if ( ! empty( $mid_roll ) || ! empty( $post_roll ) ) { $settings['email_capture'] = array( 'mid_roll' => $mid_roll, 'post_roll' => $post_roll, 'collect_name' => ! empty( $email_capture_settings['collect_name'] ) ? 1 : 0, 'collect_phone' => ! empty( $email_capture_settings['collect_phone'] ) ? 1 : 0, 'allow_skip' => ! empty( $email_capture_settings['allow_skip'] ) ? 1 : 0, 'header_text' => apply_filters( 'aiovg_translate_strings', $header_text, 'header_text' ), 'footer_text' => apply_filters( 'aiovg_translate_strings', $footer_text, 'footer_text' ), 'button_label' => apply_filters( 'aiovg_translate_strings', $button_label, 'button_label' ), 'skip_text' => apply_filters( 'aiovg_translate_strings', $skip_text, 'skip_text' ) ); } } } } $settings = apply_filters( 'aiovg_video_settings', $settings ); // Backward compatibility to 3.3.0 $settings = apply_filters( 'aiovg_iframe_videojs_player_settings', $settings ); // Trailers should not send statistics and should have limited controls to encourage users to watch the full video. if ( ! empty( $is_trailer ) ) { $tracks = array(); $settings['statistics'] = 0; unset( $settings['tracks'] ); unset( $settings['chapters'] ); unset( $settings['download'] ); } ?> 0 ) : ?> <?php echo wp_kses_post( $post_title ); ?> > ', esc_attr( $source['type'] ), esc_url( aiovg_make_url_absolute( $source['src'] ) ), ( isset( $source['label'] ) ? esc_attr( $source['label'] ) : '' ) ); } // Video Tracks foreach ( $tracks as $index => $track ) { printf( '', esc_url( aiovg_make_url_absolute( $track['src'] ) ), esc_attr( $track['label'] ), esc_attr( $track['srclang'] ), ( 0 == $index && 1 == $settings['cc_load_policy'] ? 'default' : '' ) ); } ?>