isset( $_GET['uid'] ) ? sanitize_text_field( $_GET['uid'] ) : 0, 'post_id' => $post_id, 'post_type' => $post_type, 'is_trailer' => $is_trailer, 'statistics' => isset( $general_settings['statistics'] ) ? (int) $general_settings['statistics'] : 1, 'player' => array( 'iconUrl' => AIOVG_PLUGIN_URL . 'vendor/vidstack/plyr.svg', 'volume' => 0.5 ) ); $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_iframe_vidstack_player_sources', $sources, $settings ); // Video Captions $tracks = array(); $cc_load_policy = isset( $_GET['cc_load_policy'] ) ? (int) $_GET['cc_load_policy'] : (int) $player_settings['cc_load_policy']; if ( ! empty( $post_meta['track'] ) ) { foreach ( $post_meta['track'] as $track ) { $tracks[] = maybe_unserialize( $track ); } if ( ! empty( $cc_load_policy ) ) { $settings['player']['captions'] = array( 'active' => true, 'language' => 'auto', 'update' => false ); } } $tracks = apply_filters( 'aiovg_iframe_vidstack_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['player']['markers'] = array( 'enabled' => true, 'points' => array_values( $chapters ) ); } } // Video Attributes $player_theme = ( isset( $player_settings['theme'] ) && 'custom' == $player_settings['theme'] ) ? 'custom' : 'default'; $attributes = array( 'id' => 'player', 'style' => 'width: 100%; height: 100%; --plyr-color-main: ' . esc_attr( $primary_color ) . ';', 'controls' => '', 'preload' => esc_attr( $player_settings['preload'] ) ); $autoplay = isset( $_GET['autoplay'] ) ? (int) $_GET['autoplay'] : (int) $player_settings['autoplay']; if ( $autoplay ) { $attributes['autoplay'] = ''; $settings['player']['autoplay'] = true; } $loop = isset( $_GET['loop'] ) ? (int) $_GET['loop'] : (int) $player_settings['loop']; if ( $loop ) { $attributes['loop'] = ''; $settings['player']['loop'] = array( 'active' => true ); } $muted = isset( $_GET['muted'] ) ? (int) $_GET['muted'] : (int) $player_settings['muted']; if ( $muted ) { $attributes['muted'] = ''; $settings['player']['muted'] = true; } $playsinline = ! empty( $player_settings['playsinline'] ) ? 1 : 0; if ( $playsinline ) { $attributes['playsinline'] = ''; $settings['player']['playsinline'] = true; } else { $settings['player']['playsinline'] = false; } $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['data-poster'] = aiovg_sanitize_url( aiovg_make_url_absolute( $poster ) ); } $attributes = apply_filters( 'aiovg_iframe_vidstack_player_attributes', $attributes ); // Player Controls $has_play = isset( $_GET['playpause'] ) ? (int) $_GET['playpause'] : isset( $player_settings['controls']['playpause'] ); $has_current_time = isset( $_GET['current'] ) ? (int) $_GET['current'] : isset( $player_settings['controls']['current'] ); $has_progress = isset( $_GET['progress'] ) ? (int) $_GET['progress'] : isset( $player_settings['controls']['progress'] ); $has_duration = isset( $_GET['duration'] ) ? (int) $_GET['duration'] : isset( $player_settings['controls']['duration'] ); $has_volume = isset( $_GET['volume'] ) ? (int) $_GET['volume'] : isset( $player_settings['controls']['volume'] ); $has_quality_selector = isset( $_GET['quality'] ) ? (int) $_GET['quality'] : isset( $player_settings['controls']['quality'] ); $has_captions = isset( $_GET['tracks'] ) ? (int) $_GET['tracks'] : isset( $player_settings['controls']['tracks'] ); $has_speed_control = isset( $_GET['speed'] ) ? (int) $_GET['speed'] : isset( $player_settings['controls']['speed'] ); $has_pip = isset( $_GET['pip'] ) ? (int) $_GET['pip'] : isset( $player_settings['controls']['pip'] ); $has_fullscreen = isset( $_GET['fullscreen'] ) ? (int) $_GET['fullscreen'] : isset( $player_settings['controls']['fullscreen'] ); $controls = array(); $controls[] = 'play-large'; if ( $has_play ) { $controls[] = 'play'; } if ( 'custom' === $player_theme ) { if ( $has_progress ) { $controls[] = 'progress'; } if ( $has_current_time ) { $controls[] = 'current-time'; } } else { if ( $has_current_time ) { $controls[] = 'current-time'; } if ( $has_progress ) { $controls[] = 'progress'; } } if ( $has_duration ) { $controls[] = 'duration'; } if ( 'custom' === $player_theme ) { $controls[] = 'restart'; } if ( $has_volume ) { $controls[] = 'mute'; if ( ! wp_is_mobile() ) { $controls[] = 'volume'; } } if ( $has_captions ) { if ( ! wp_is_mobile() ) { $controls[] = 'captions'; } } else { if ( empty( $cc_load_policy ) ) { $tracks = array(); } } if ( $has_quality_selector || $has_captions || $has_speed_control ) { $controls[] = 'settings'; $settings['player']['settings'] = array(); if ( $has_quality_selector ) { $settings['player']['settings'][] = 'quality'; } if ( $has_captions ) { $settings['player']['settings'][] = 'captions'; } if ( $has_speed_control ) { $settings['player']['settings'][] = 'speed'; $settings['player']['speed'] = array( 'selected' => 1, 'options' => array( 0.5, 0.75, 1, 1.5, 2 ) ); } } 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 ) { $controls[] = 'download'; if ( empty( $download_url ) ) { $download_url = home_url( '?vdl=' . aiovg_get_temporary_file_download_id( $sources['mp4']['src'] ) ); } $settings['player']['urls'] = array( 'download' => esc_url( $download_url ) ); } } if ( $has_pip ) { $controls[] = 'pip'; } if ( $has_fullscreen ) { $controls[] = 'fullscreen'; $settings['player']['fullscreen'] = array( 'enabled' => true, 'iosNative' => true ); } $settings['player']['controls'] = $controls; // Keyboard Hotkeys if ( isset( $player_settings['hotkeys'] ) && ! empty( $player_settings['hotkeys'] ) ) { $settings['player']['keyboard'] = array( 'focused' => true, 'global' => true ); } // YouTube if ( isset( $sources['youtube'] ) ) { $settings['player']['youtube'] = array( 'noCookie' => false, 'rel' => 0, 'showinfo' => 0, 'iv_load_policy' => 3, 'modestbranding' => 1 ); parse_str( $sources['youtube']['src'], $queries ); if ( isset( $queries['start'] ) ) { $settings['player']['youtube']['start'] = (int) $queries['start']; } if ( isset( $queries['t'] ) ) { $settings['player']['youtube']['start'] = (int) $queries['t']; } if ( isset( $queries['end'] ) ) { $settings['player']['youtube']['end'] = (int) $queries['end']; } } // Vimeo if ( isset( $sources['vimeo'] ) ) { $settings['player']['vimeo'] = array( 'byline' => false, 'portrait' => false, 'title' => false, 'speed' => true, 'transparent' => false ); } // HLS if ( isset( $sources['hls'] ) ) { $settings['hls'] = $sources['hls']['src']; $settings['player']['captions'] = array( 'active' => ! empty( $cc_load_policy ) ? true : false, 'language' => 'auto', 'update' => true ); } // Dash if ( isset( $sources['dash'] ) ) { $settings['dash'] = $sources['dash']['src']; $settings['player']['captions'] = array( 'active' => ! empty( $cc_load_policy ) ? true : false, 'language' => 'auto', 'update' => true ); } // 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['data-poster'] ) ? $attributes['data-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; } // 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_iframe_vidstack_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['player']['captions'] ); unset( $settings['player']['markers'] ); if ( ! empty( $settings['player']['controls'] ) ) { $settings['player']['controls'] = array_values( array_diff( $settings['player']['controls'], array( 'download' ) ) ); } } ?> 0 ) : ?>