isset( $_GET['uid'] ) ? sanitize_text_field( $_GET['uid'] ) : 0, 'post_id' => $post_id, 'post_type' => $post_type, '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, 'i18n' => array( 'stream_not_found' => __( 'This stream is currently not live. Please check back or refresh your page.', 'all-in-one-video-gallery' ) ), 'player' => array( 'controlBar' => array(), 'playbackRates' => array( 0.5, 0.75, 1, 1.5, 2 ), 'suppressNotSupportedError' => true ) ); $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', 'dailymotion' ); 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_video_sources', $sources ); // Backward compatibility to 3.3.0 $sources = apply_filters( 'aiovg_iframe_videojs_player_sources', $sources ); // Video Tracks $tracks = array(); $has_tracks = isset( $_GET['tracks'] ) ? (int) $_GET['tracks'] : isset( $player_settings['controls']['tracks'] ); if ( $has_tracks && ! empty( $post_meta['track'] ) ) { foreach ( $post_meta['track'] as $track ) { $tracks[] = 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 && ! 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['chapters'] = $chapters; } } // Video Attributes $attributes = array( 'id' => 'player', 'class' => 'vjs-fill', '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 ) { $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 = $_GET['poster']; } elseif ( ! empty( $post_meta ) ) { $image_data = aiovg_get_image( $post_id, 'large' ); $poster = $image_data['src']; } if ( ! empty( $poster) ) { $attributes['poster'] = aiovg_sanitize_url( aiovg_resolve_url( $poster ) ); } if ( ! empty( $brand_settings ) && ! empty( $brand_settings['copyright_text'] ) ) { $attributes['controlsList'] = 'nodownload'; $attributes['oncontextmenu'] = 'return false;'; } $attributes = apply_filters( 'aiovg_video_attributes', $attributes ); // Backward compatibility to 3.3.0 $attributes = apply_filters( 'aiovg_iframe_videojs_player_attributes', $attributes ); // Player Settings $controls = array( 'playpause' => 'PlayToggle', 'current' => 'CurrentTimeDisplay', 'progress' => 'progressControl', 'duration' => 'durationDisplay', 'tracks' => 'SubtitlesButton', 'audio' => 'AudioTrackButton', 'speed' => 'PlaybackRateMenuButton', 'quality' => 'qualitySelector', 'volume' => 'VolumePanel', 'fullscreen' => 'fullscreenToggle' ); foreach ( $controls as $index => $control ) { $enabled = isset( $_GET[ $index ] ) ? (int) $_GET[ $index ] : isset( $player_settings['controls'][ $index ] ); if ( $enabled && 'tracks' == $index ) { $player_settings['controls']['audio'] = 1; } if ( ! $enabled ) { unset( $controls[ $index ] ); } } $settings['player']['controlBar']['children'] = array_values( $controls ); if ( empty( $settings['player']['controlBar']['children'] ) ) { $attributes['class'] = 'vjs-no-control-bar'; } // 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']; } } // 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; } } // Dailymotion if ( isset( $sources['dailymotion'] ) ) { $settings['player']['techOrder'] = array( 'dailymotion' ); } // 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['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}", '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; } // 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' => 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_video_settings', $settings ); // Backward compatibility to 3.3.0 $settings = apply_filters( 'aiovg_iframe_videojs_player_settings', $settings ); ?> 0 ) : ?>