isset( $_GET['uid'] ) ? sanitize_text_field( $_GET['uid'] ) : 0, 'post_id' => $post_id, 'post_type' => $post_type, 'player' => array( '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 = 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_sanitize_url( $_GET[ $type ] ); $sources[ $type ] = array( 'type' => $mime_type, 'src' => $src ); } } } $sources = apply_filters( 'aiovg_iframe_vidstack_player_sources', $sources ); // 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[] = 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 && ! empty( $post_meta['chapter'] ) ) { $chapters = array(); foreach ( $post_meta['chapter'] as $chapter ) { $chapter = unserialize( $chapter ); $chapters[] = array( 'label' => sanitize_text_field( $chapter['label'] ), 'time' => (float) $chapter['time'] ); } if ( ! empty( $chapters ) ) { $settings['player']['markers'] = array( 'enabled' => true, 'points' => $chapters ); } } // Video Attributes $attributes = array( 'id' => 'player', 'style' => 'width: 100%; height: 100%;', '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 = $_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_resolve_url( $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_fullscreen = isset( $_GET['fullscreen'] ) ? (int) $_GET['fullscreen'] : isset( $player_settings['controls']['fullscreen'] ); $controls = array(); $controls[] = 'play-large'; if ( $has_play ) { $controls[] = 'play'; } if ( $has_current_time ) { $controls[] = 'current-time'; } if ( $has_progress ) { $controls[] = 'progress'; } if ( $has_duration ) { $controls[] = 'duration'; } 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_fullscreen ) { $controls[] = 'fullscreen'; } $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 = get_option( 'aiovg_socialshare_settings' ); $share_url = $post_url; $share_title = $post_title; $share_title = str_replace( ' ', '%20', $share_title ); $share_title = str_replace( '|', '%7C', $share_title ); $share_title = str_replace( '@', '%40', $share_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}", '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}", '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}&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}&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}&name={$share_title}"; $share_description = aiovg_get_excerpt( $post_id, 160, '', false ); if ( ! empty( $share_description ) ) { $share_description = str_replace( ' ', '%20', $share_description ); $share_description = str_replace( '|', '%7C', $share_description ); $share_description = str_replace( '@', '%40', $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} " . rawurlencode( $share_url ); } else { $whatsapp_url = "https://api.whatsapp.com/send?text={$share_title} {$share_url}"; } $share_buttons[] = array( 'service' => 'whatsapp', 'url' => $whatsapp_url, 'icon' => 'aiovg-icon-whatsapp', 'text' => __( 'WhatsApp', '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' => aiovg_sanitize_url( aiovg_resolve_url( $brand_settings['logo_image'] ) ), 'link' => ! empty( $brand_settings['logo_link'] ) ? esc_url_raw( $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' => apply_filters( 'aiovg_translate_strings', sanitize_text_field( $brand_settings['copyright_text'] ), 'copyright_text' ) ); } } $settings = apply_filters( 'aiovg_iframe_vidstack_player_settings', $settings ); ?> 0 ) : ?> <?php echo wp_kses_post( $post_title ); ?> ', esc_attr( $attributes['id'] ), esc_attr( $attributes['style'] ), esc_attr( $video_id ), ( isset( $attributes['data-poster'] ) ? esc_attr( $attributes['data-poster'] ) : '' ) ); } // Vimeo elseif ( isset( $sources['vimeo'] ) ) { $video_id = aiovg_get_vimeo_id_from_url( $sources['vimeo']['src'] ); printf( '
', esc_attr( $attributes['id'] ), esc_attr( $attributes['style'] ), esc_attr( $video_id ), ( isset( $attributes['data-poster'] ) ? esc_attr( $attributes['data-poster'] ) : '' ) ); } // HLS or Dash elseif ( isset( $sources['hls'] ) || isset( $sources['dash'] ) ) { printf( '', aiovg_combine_video_attributes( $attributes ) ); } // HTML5 Video elseif ( ! empty( $sources ) ) { printf( ''; } ?>