芝麻web文件管理V1.00
编辑当前文件:/home/felaukpo/public_html/wp-content/themes/pixelpiernyc/vamtam/classes/video-player.php
is_embedded = $is_embedded; $this->src_mp4 = $src_mp4; $this->src_webm = $src_webm; $this->muted = $muted; $this->fallback_src = $fallback_src; $this->video_zoom = $video_zoom; $this->init(); } private function youtube_valid_vid_id( $url ) { $p = '/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/'; $res = preg_match( $p, $url, $matches ); if ( ! $res ) { return false; } return $matches; } private function vimeo_valid_vid_id( $url ) { $p = '/(http|https)?:\/\/(www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|)(\d+)(?:|\/\?)/'; $res = preg_match( $p, $url, $matches ); if ( ! $res ) { return false; } return $matches; } private function get_iframe_player() { $src = $this->src_mp4; $is_valid_src = ! empty( $src ) && is_string( $src ) && ( $this->youtube_valid_vid_id( $src ) || $this->vimeo_valid_vid_id( $src ) ); $fallback = '
'; $should_show_fallback = ! empty( $this->fallback_src ) ? $fallback : ''; $classes = 'vt-embed-vp-wrap'; $is_valid_src && $classes .= ' has-vid'; $html = '
' . ( $is_valid_src ? $this->create_iframe_player() : $should_show_fallback ) . '
'; return $html; } private function create_iframe_player() { $src = $this->src_mp4; $video_id; $is_youtube = $this->youtube_valid_vid_id( $src ); if ( $is_youtube ) { $video_id = $is_youtube[1]; } elseif ( $this->vimeo_valid_vid_id( $src ) ) { $video_id = $this->vimeo_valid_vid_id( $src )[4]; } else { return ''; } $embed = $is_youtube ? 'https://www.youtube.com/embed/' . $video_id . '?controls=0&showinfo=0&loop=1&playlist=' . $video_id . '&rel=0&start=0&mute=' . ( $this->muted ? '1' : '0' ) . '&disablekb=1&enablejsapi=1' : 'https://player.vimeo.com/video/' . $video_id . '?title=0&portrait=0&muted=' . ( $this->muted ? '1' : '0' ) . '&autopause=0&loop=1&background=0&byline=0&speed=0'; $html = '
'; return $html; } private function get_html5_video_player() { $html = '
muted ? ' muted ' : '' ) . ' loop poster=' . esc_url( $this->fallback_src ) . '>
'; return $html; } public function init() { $html = '
' . ( $this->is_embedded ? $this->get_iframe_player() : $this->get_html5_video_player() ) . '
'; $this->player = $html; } public function get_player() { return $this->player; } }