diff options
Diffstat (limited to 'vinotjs/vinotjs.php')
-rw-r--r-- | vinotjs/vinotjs.php | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/vinotjs/vinotjs.php b/vinotjs/vinotjs.php new file mode 100644 index 0000000..1ab4be2 --- /dev/null +++ b/vinotjs/vinotjs.php @@ -0,0 +1,165 @@ +<?php + +/* Implementación de LibreVideoJS +==============================================================================================*/ +include_once 'libre-panel.php'; + +if (!class_exists('VINOTJS')){ + + class VINOTJS{ + + function __construct(){ + $this->theme_includes(); + } + + function theme_includes(){ + if (!is_admin()) { + add_shortcode('vinotjs', 'ViNotJS_embed'); + //allows shortcode execution in the widget, excerpt and content + add_filter('widget_text', 'do_shortcode'); + add_filter('the_excerpt', 'do_shortcode', 11); + add_filter('the_content', 'do_shortcode', 11); + } + } + } + + $GLOBALS['easy_video_player'] = new VINOTJS(); + new vinotjs_panel_shortcode(); +} + +function ViNotJS_embed($atts, $content=null){ + extract(shortcode_atts(array( + 'url' => '', + 'code' => '', + 'width' => '', + 'controls' => '', + 'preload' => 'auto', + 'autoplay' => 'false', + 'loop' => '', + 'muted' => '', + 'poster' => '', + ), $atts)); + + if(empty($url)){ + return __('you need to specify the src of the video file', 'Lidra'); + } + + // support youtube without DRM + require 'processor.php'; + + //src + if(!empty($url) && strlen($id) === 11 ){ + $src = '<source src="'. $videoyt .'" type="'. $format .'"/>'; + } else { + $src = '<source src="'.$url.'" type="video/'.$code.'"/>'; + } + + //controls + if($controls == "false"){ + $controls = ""; + } + else{ + $controls = "controls"; + } + + //preload + if($preload == "metadata"){ + $preload = ' preload="metadata"'; + } + else if($preload == "none"){ + $preload = ' preload="none"'; + } + else{ + $preload = ' preload="auto"'; + } + + //autoplay + if($autoplay == "true"){ + $autoplay = " autoplay"; + } + else{ + $autoplay = ""; + } + + //loop + if($loop == "true"){ + $loop = " loop"; + } + else{ + $loop = ""; + } + + //muted + if($muted == "true"){ + $muted = " muted"; + } + else{ + $muted = ""; + } + + //Tracks + if(!is_null( $content )){ + $track = do_shortcode($content); + } + else{ + $track = ""; + } + + //poster + if(!empty($poster)){ + $poster = " poster='$poster'"; + } + + //languages + $_no_html5 = __('Sorry, this video will not work because your web browser does not support HTML5 video. Please, change or update your browser', 'Lidra'); + + $_no_browser = '<p>' . $_no_html5 . '</p>'; + + $output = <<<EOT + <div class="vinotjs"> + <video {$controls}{$preload}{$autoplay}{$loop}{$muted}{$poster}> + {$src}\n\t\t{$track}{$_no_browser} + </video> + </div> +EOT; + return $output; +} + +/*Adding subtitles using... [track]*/ +function track_vinotjs($atts, $content=null){ + extract(shortcode_atts(array( + 'kind' => '', + 'subt' => '', + 'srclang' => '', + 'label' => '', + 'default' => '', + ), $atts)); + + if($kind){ + $kind = " kind='$kind'"; + } + + if($subt){ + $subt = " src='$subt'"; + } + + if($srclang){ + $srclang = " srclang='$srclang'"; + } + + if($label){ + $label = " label='$label'"; + } + + if($default == "true" || $default == "default"){ + $default = " default"; + } + else{ + $default = ""; + } + + $track = "<track" . $kind . $subt . $srclang . $label . $default . "/>\n\t\t"; + + return $track; +} +add_shortcode('track', 'track_vinotjs');
\ No newline at end of file |