aboutsummaryrefslogtreecommitdiffstats
path: root/vinotjs/vinotjs.php
blob: 8e1337e29931838c7d43dc1a1f6fb805f368894a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?php

/* Implementación de ViNotJS
==============================================================================================*/
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');