PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.8
WpStream – Live Streaming, Video on Demand, Pay Per View v3.8
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
← All changes | includes/class-wpstream-player.php +470 -1368 4.123.8 View file →
@@ -12,20 +12,10 @@
12 12 *
13 13 * @author cretu
14 14 */
15 15 class Wpstream_Player{
16 - public $main;
17 -
18 - /**
19 - * @var Wpstream_Playback_Session
20 - */
21 - public $playback_session;
22 -
23 16 public function __construct($plugin_main) {
24 17 $this->main = $plugin_main;
25 -
26 - require_once dirname( __FILE__ ) . '/player/class-wpstream-playback-session.php';
27 - $this->playback_session = new Wpstream_Playback_Session();
28 18
29 19 add_filter( 'the_content',array($this, 'wpstream_filter_the_title') );
30 20 add_action( 'woocommerce_before_single_product', array($this,'wpstream_user_logged_in_product_already_bought') );
31 21
@@ -30,20 +20,37 @@
30 20 add_action( 'woocommerce_before_single_product', array($this,'wpstream_user_logged_in_product_already_bought') );
31 21
32 22 add_action( 'wp_ajax_wpstream_player_check_status', array($this,'wpstream_player_check_status') );
33 23 add_action('wp_ajax_nopriv_wpstream_player_check_status', array($this,'wpstream_player_check_status'));
34 -
24 +
25 +
26 + add_action( 'wp_ajax_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient') );
27 + add_action('wp_ajax_nopriv_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient'));
28 +
29 +
35 30 }
36 31
37 32
38 33
39 -
34 + /**
35 + * clear status transients
36 + *
37 + * @author cretu
38 + */
40 39
40 +
41 + public function wpstream_force_clear_transient($event_id){
42 +
43 + $transient_name = 'event_data_to_return_'.$event_id;
44 + delete_transient($transient_name);
45 + update_post_meta($event_id,'statsUrl','');
46 + update_post_meta($event_id,'chatUrl','');
41 47
48 + }
49 +
50 +
51 +
42 52 /**
43 - *
44 - * edited 4.0
45 - *
46 53 * check player status
47 54 *
48 55 * @author cretu
49 56 */
@@ -48,64 +55,115 @@
48 55 * @author cretu
49 56 */
50 57
51 58 public function wpstream_player_check_status(){
52 - // did not add a nonce check here because this is a call done from the frontend
53 - // and the page might be cached, so the nonce would not be valid
54 - $channel_id = intval($_POST['channel_id']);
55 -
59 + $event_id = intval($_POST['event_id']);
60 + $show_id=$event_id;
61 + $transient_name = 'event_data_to_return_'.$event_id;
62 + $event_data_for_transient = get_transient( $transient_name );
63 +
64 +
56 65
57 - $transient_name = 'event_data_to_return_'. $channel_id;
58 - $event_data_for_transient = get_transient( $transient_name );
66 + if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
67 +
68 + $server_id = ''; // server id IS blank - need to retrive it
69 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
70 +
71 + if($server_id==''){
72 + update_post_meta($show_id,'server_id', '' );
73 +
74 + $server_id =$this->main->wpstream_live_connection->retrive_server_id_based_on_show_id($show_id);
75 +
76 + }
77 +
78 +
79 +
80 + update_post_meta($show_id,'server_id', $server_id );
81 + $values_array=array(
82 + "server_id" => esc_html($server_id),
83 + 'from_where' => 'wpstream_check_event_status_front_player'
84 + );
85 +
86 + if($server_id==''){
87 + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
88 + //print 'failed connection';
89 + return;
90 + }
91 +
59 92
60 -
61 - $usefull_info =' get cache from transiet';
62 - if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
63 - $notes = 'wpstream_player_check_status_note_from_js';
64 - $event_status = $this->main->wpstream_live_connection->wpstream_check_event_status_api_call($channel_id,$notes);
65 - $event_data_for_transient = $event_status;
66 - $usefull_info =' no cache found';
67 - set_transient($transient_name,$event_data_for_transient,45);
93 +
94 + $url=WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/event_status/?access_token=".$token;
95 + $arguments = array(
96 + 'method' => 'GET',
97 + 'timeout' => 45,
98 + 'redirection' => 5,
99 + 'httpversion' => '1.0',
100 + 'blocking' => true,
101 + 'headers' => array(),
102 + 'body' => $values_array,
103 + 'cookies' => array()
104 + );
105 +
106 + $response = wp_remote_post($url,$arguments);
107 + $received_data = wp_remote_retrieve_body($response);
108 +
109 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
110 + $received_data_encoded=json_decode($received_data,true);
111 +
112 + if( isset($received_data_encoded['success']) && intval( $received_data_encoded['success'] ) ==1 ){
113 +
114 + /*
115 + * we set transient and return the array saved
116 + * false if no data
117 + *
118 + * */
119 + $event_data_for_transient= $this->main->wpstream_live_connection->api20_wpstream_update_event($received_data_encoded,$show_id,$server_id);
120 + }else{
121 + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
122 + }
123 +
124 + }else{
125 + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
126 + }
127 +
128 +
129 +
130 +
131 + if ( false === $event_data_for_transient || $event_data_for_transient=='' ){
132 + //we are not live
133 + $event_data_for_transient=array();
134 + $event_data_for_transient['hlsPlaybackUrl']='';
135 +
136 + }
68 137 }
69 138
70 139
71 - if( isset($event_data_for_transient['hls_playback_url']) && $event_data_for_transient['hls_playback_url']!=''){
72 - // cleanup any previous echo before sending json
73 - ob_end_clean();
140 +
141 + // 1==2 &&
142 +
143 + if( $event_data_for_transient['hlsPlaybackUrl']!=''){
74 144 echo json_encode( array(
75 145
76 146 'started' => 'yes',
77 - 'usefull_info' => $usefull_info,
78 - 'channel_id' => $channel_id,
79 - 'event_uri' => $event_data_for_transient['hls_playback_url'],
80 - 'live_conect_views' => $event_data_for_transient['stats_url'],
81 - 'chat_url' => $event_data_for_transient['chat_url'],
82 - '$event_data_for_transient'=>$event_data_for_transient
83 -
147 + 'server_id' => $event_data_for_transient['server_id'],
148 + 'event_id' => $event_id,
149 + 'event_uri' => $event_data_for_transient['hlsPlaybackUrl'],
150 + 'live_conect_views' => $event_data_for_transient['statsUrl'],
151 + 'chat_url' => $event_data_for_transient['chatUrl'],
84 152
85 153 ));
86 - $usedfull_info =' ';
87 - update_post_meta($channel_id,'stream_name',$event_data_for_transient['stream_name']);
88 - update_post_meta($channel_id,'hls_key_retrieval_url',$event_data_for_transient['hls_key_retrieval_url']);
89 - delete_transient( 'free_event_streamName_'.$event_data_for_transient['stream_name']);
90 -
91 154 }else{
92 - // cleanup any previous echo before sending json
93 - ob_end_clean();
94 155 echo json_encode( array(
95 156 'started' => 'no',
96 - 'usefull_info' => $usefull_info,
97 - 'server_id' => '',
98 - 'channel_id' => $channel_id,
157 + 'server_id' => $server_id,
158 + 'event_id' => $event_id,
99 159 'event_uri' => '',
100 160 'live_conect_views' => '',
101 161 'chat_url' => '',
102 -
103 162
104 163 ));
105 -
164 + $this->wpstream_force_clear_transient($event_id);
106 165 }
107 -
108 166 die();
109 167 }
110 168
111 169
@@ -115,13 +173,9 @@
115 173 *
116 174 * @author cretu
117 175 */
118 176 public function wpstream_filter_the_title( $content ) {
119 - if(function_exists('wpstream_remove_wpstream_filter')){
120 - return $content;
121 - }
122 -
123 - if( is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){
177 + if( is_singular('wpstream_product')){
124 178 global $post;
125 179 $args=array('id'=>$post->ID);
126 180 $custom_content = $this->wpstream_insert_player_inpage($args);
127 181 $content = '<div class="wpestream_inserted_player">'.$custom_content.'</div>'.$content;
@@ -172,42 +226,31 @@
172 226 * @author cretu
173 227 */
174 228
175 229 public function wpstream_video_player_shortcode($from_sh_id='') {
176 - // disable cache in order to be able to check the nonce
177 - if ( !defined( 'DONOTCACHEPAGE' ) ) {
178 - define( 'DONOTCACHEPAGE', true );
179 - }
180 230
181 - wp_enqueue_script('video.min');
182 - wp_enqueue_script('wpstream-player');
183 -
184 231 if ( is_user_logged_in() ) {
185 232 global $product;
186 233 $current_user = wp_get_current_user();
187 234 $product_id = intval($from_sh_id);
188 - $term_list = wp_get_post_terms($product_id, 'product_type');
189 - $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle', true);
190 -
191 235
192 236
193 -
194 - if (
195 -
196 - ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ) ||
197 - ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && (intval($possible_bundle)!=0) && wc_customer_bought_product( $current_user->user_email, $current_user->ID, $possible_bundle) ) ||
198 - get_post_type($product_id)=='wpstream_product' ||
199 - get_post_type($product_id)=='wpstream_product_vod' ){
237 + if ( ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ) || get_post_type($product_id)=='wpstream_product' ){
200 238 global $product;
201 239 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
202 240
203 241
204 242 if( get_post_type($product_id) == 'wpstream_product' ){
205 - $this->wpstream_live_event_player($product_id);
206 - }else if( get_post_type($product_id) == 'wpstream_product_vod' ){
207 - $this->wpstream_video_on_demand_player($product_id);
243 +
244 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
245 + if($wpstream_product_type==1){
246 + $this->wpstream_live_event_player($product_id);
247 + } else if($wpstream_product_type==2 || $wpstream_product_type==3){
248 + $this->wpstream_video_on_demand_player($product_id);
249 + }
250 +
208 251 }else{
209 -
252 + $term_list = wp_get_post_terms($product_id, 'product_type');
210 253 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
211 254
212 255 if( $term_list[0]->name=='live_stream' || ( $term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
213 256 $this->wpstream_live_event_player($product_id);
@@ -221,10 +264,9 @@
221 264 }else{
222 265
223 266 if( get_post_type($product_id) == 'product' ){
224 267 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
225 - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
226 - echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>';
268 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
227 269 echo '</div></div>';
228 270 }
229 271 }
230 272
@@ -231,26 +273,17 @@
231 273
232 274 }else{
233 275
234 276 $product_id = intval($from_sh_id);
235 - $term_list = wp_get_post_terms($product_id, 'product_type');
236 -
237 - if( get_post_type($product_id) == 'product' && ($term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand') ){
238 -
239 - echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
240 - $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
277 + if( get_post_type($product_id) == 'wpstream_product' ){
241 278
279 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
280 + if($wpstream_product_type==1){
281 + $this->wpstream_live_event_player($product_id);
282 + } else if($wpstream_product_type==2 || $wpstream_product_type==3){
283 + $this->wpstream_video_on_demand_player($product_id);
284 + }
242 285
243 - echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>';
244 - echo '</div></div>';
245 - }elseif( get_post_type($product_id) == 'wpstream_product' ){
246 - echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
247 - $this->wpstream_live_event_player($product_id);
248 - echo '</div></div>';
249 - } else if( get_post_type($product_id) == 'wpstream_product_vod' ){
250 - echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
251 - $this->wpstream_video_on_demand_player($product_id);
252 - echo '</div></div>';
253 286 }
254 287 }
255 288 }
256 289
@@ -262,16 +295,9 @@
262 295 * @author cretu
263 296 */
264 297
265 298 public function wpstream_video_player_shortcode_low_latency($from_sh_id='') {
266 - if ( !defined( 'DONOTCACHEPAGE' ) ) {
267 - define( 'DONOTCACHEPAGE', true );
268 - }
269 299
270 - wp_enqueue_script('video.min');
271 - wp_enqueue_script('wpstream-player');
272 -
273 -
274 300 if ( is_user_logged_in() ) {
275 301 global $product;
276 302 $current_user = wp_get_current_user();
277 303 $product_id = intval($from_sh_id);
@@ -282,9 +308,14 @@
282 308 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
283 309
284 310
285 311 if( get_post_type($product_id) == 'wpstream_product' ){
286 - $this->wpstream_live_event_player_low_latency($product_id);
312 +
313 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
314 + if($wpstream_product_type==1){
315 + $this->wpstream_live_event_player_low_latency($product_id);
316 + }
317 +
287 318 }else{
288 319 $term_list = wp_get_post_terms($product_id, 'product_type');
289 320 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
290 321
@@ -298,11 +329,9 @@
298 329 }else{
299 330
300 331 if( get_post_type($product_id) == 'product' ){
301 332 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
302 -
303 - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
304 - echo '<div class="wpstream_notice" style="background:#e16767;">'.$message.'</div>';
333 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
305 334 echo '</div></div>';
306 335 }
307 336 }
308 337
@@ -309,9 +338,13 @@
309 338
310 339 }else{
311 340 $product_id = intval($from_sh_id);
312 341 if( get_post_type($product_id) == 'wpstream_product' ){
313 - $this->wpstream_live_event_player_low_latency($product_id);
342 +
343 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
344 + if($wpstream_product_type==1){
345 + $this->wpstream_live_event_player_low_latency($product_id);
346 + }
314 347 }
315 348 }
316 349 }
317 350
@@ -332,114 +365,8 @@
332 365 }
333 366 }
334 367 return $url;
335 368 }
336 -
337 - /**
338 - * Site origin (scheme://host:port) for the new player `embedAncestor` query param.
339 - * The player includes this value in the embed-key hash; mint keys with the same string.
340 - *
341 - * @return string
342 - */
343 - private function wpstream_get_site_origin_for_embed() {
344 - $parts = wp_parse_url( home_url() );
345 - if ( empty( $parts['host'] ) ) {
346 - return '';
347 - }
348 - $scheme = isset( $parts['scheme'] ) ? $parts['scheme'] . '://' : 'https://';
349 - $host = $parts['host'];
350 - $port = isset( $parts['port'] ) ? ':' . $parts['port'] : '';
351 - return $scheme . $host . $port;
352 - }
353 -
354 - /**
355 - * Keep this in sync with player/src/config/env.js fallback.
356 - *
357 - * @return string
358 - */
359 - private function wpstream_get_player_embed_key_salt() {
360 - $default_salt = 'EYjb84vNTXE85TfR';
361 - $configured = trim( (string) get_option( 'wpstream_player_embed_key_salt', '' ) );
362 - $base_salt = '' !== $configured ? $configured : $default_salt;
363 -
364 - return (string) apply_filters( 'wpstream_player_embed_key_salt', $base_salt );
365 - }
366 -
367 - /**
368 - * Masked salt metadata for debugging embed-key mismatches.
369 - *
370 - * @return array<string,mixed>
371 - */
372 - private function wpstream_get_player_embed_key_salt_debug_meta() {
373 - $default_salt = 'EYjb84vNTXE85TfR';
374 - $configured = trim( (string) get_option( 'wpstream_player_embed_key_salt', '' ) );
375 - $base_salt = '' !== $configured ? $configured : $default_salt;
376 - $final_salt = (string) apply_filters( 'wpstream_player_embed_key_salt', $base_salt );
377 - $len = strlen( $final_salt );
378 - $prefix = $len > 0 ? substr( $final_salt, 0, min( 2, $len ) ) : '';
379 - $suffix = $len > 2 ? substr( $final_salt, -2 ) : '';
380 -
381 - return array(
382 - 'source' => '' !== $configured ? 'option_or_filter' : 'default_or_filter',
383 - 'length' => $len,
384 - 'sha256_12' => substr( hash( 'sha256', $final_salt ), 0, 12 ),
385 - 'maskedPreview' => $prefix . ( $len > 0 ? '***' : '' ) . $suffix,
386 - );
387 - }
388 -
389 - /**
390 - * Mirror player/src/security/embed-key.js hash generation.
391 - *
392 - * @param string $video Media path used by /player/vod?video=...
393 - * @param string $validate_playback_session_url Optional session verify URL.
394 - * @param string $embed_ancestor Optional frame ancestor origin.
395 - * @param string $encrypt_raw Optional encrypt toggle (yes/true/1).
396 - * @return string
397 - */
398 - private function wpstream_generate_player_embed_key( $video, $validate_playback_session_url = '', $embed_ancestor = '', $encrypt_raw = '' ) {
399 - $video = trim( (string) $video );
400 - if ( '' === $video ) {
401 - return '';
402 - }
403 -
404 - $hash_input = $video . ' ' . $this->wpstream_get_player_embed_key_salt();
405 - $validate_playback_session_url = trim( (string) $validate_playback_session_url );
406 - if ( '' !== $validate_playback_session_url ) {
407 - $hash_input = $validate_playback_session_url . ' ' . $hash_input;
408 - }
409 -
410 - $embed_ancestor = trim( (string) $embed_ancestor );
411 - if ( '' !== $embed_ancestor ) {
412 - $hash_input = $embed_ancestor . ' ' . $hash_input;
413 - }
414 -
415 - $encrypt_raw = strtolower( trim( (string) $encrypt_raw ) );
416 - if ( in_array( $encrypt_raw, array( 'yes', 'true', '1' ), true ) ) {
417 - $hash_input = 'crypt ' . $hash_input;
418 - }
419 -
420 - $binary_hash = md5( $hash_input, true );
421 - $base64 = base64_encode( $binary_hash );
422 -
423 - return rtrim( strtr( $base64, '+/', '-_' ), '=' );
424 - }
425 -
426 - function wpstream_get_live_connect_uri($event_status, $playback_url_key = 'hls_playback_url') {
427 - if (isset($event_status['stats_url']) && trim($event_status['stats_url']) !== '') {
428 - return trim($event_status['stats_url']);
429 - }
430 -
431 - if (
432 - isset($event_status[$playback_url_key]) &&
433 - trim($event_status[$playback_url_key]) !== '' &&
434 - strpos($event_status[$playback_url_key], 'live.streamer.wpstream.net') !== false
435 - ) {
436 - $live_conect_array = explode('live.streamer.wpstream.net', $event_status[$playback_url_key]);
437 - return $this->remove_http($live_conect_array[0] . 'live.streamer.wpstream.net');
438 - }
439 -
440 - return '';
441 - }
442 369
443 370 /**
444 371 * Get event settings
445 372 *
@@ -447,13 +374,10 @@
447 374 */
448 375
449 376 function wpestream_return_event_settings($product_id){
450 377
451 - $local_event_options = get_post_meta( $product_id, 'local_event_options', true);
452 - $use_global_event_options = get_post_meta($product_id, 'use_global_event_options',true);
453 - $is_local_event_options_enabled = is_array( $local_event_options ) || intval( $use_global_event_options ) === 1;
454 -
455 - if( !$is_local_event_options_enabled ) {
378 + $local_event_options = get_post_meta($product_id,'local_event_options',true);
379 + if(!is_array($local_event_options)){
456 380 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
457 381 }
458 382
459 383 return $local_event_options;
@@ -461,270 +385,145 @@
461 385
462 386
463 387
464 388 /**
465 - * edited in 4.0
466 - *
467 389 * Live Event Player
468 390 *
469 391 * @author cretu
470 392 */
471 393
472 - function wpstream_live_event_player($channel_id,$poster_show='',$use_chat=''){
473 - wp_enqueue_script('video.min');
474 - wp_enqueue_script('wpstream-player');
394 + function wpstream_live_event_player($product_id,$poster_show='',$use_chat=''){
395 +
396 + $event_settings = $this->wpestream_return_event_settings($product_id);
397 + $live_event_uri = get_post_meta($product_id,'live_event_uri',true);
398 + $api20_event_id = get_post_meta($product_id,'server_id',true);
399 +
400 + $thumb_id = get_post_thumbnail_id($product_id);
401 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
475 402
476 -
477 - $player_theme = $this->wpstream_get_player_theme( $channel_id );
478 - $now = time().rand(0,1000000);
479 - $overlay_video_div_id = "random_id_".$now;
480 - // print '<div id="'.esc_attr($overlay_video_div_id).'" class="vjs-title-overlay wpstream-video-title-overlay">'.esc_html__('Playing:','wpstream').' '.get_the_title($channel_id).'</div>';
481 -
482 -
483 - $thumb_id = get_post_thumbnail_id($channel_id);
484 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
485 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
486 - $autoplay = true;
487 -
488 - $event_settings = $this->wpestream_return_event_settings($channel_id);
489 -
490 - $transient_name = 'event_data_to_return_'. $channel_id;
491 - $event_status = get_transient( $transient_name );
492 -
493 - if ( false === $event_status || $event_status=='' ) {
494 - $notes = 'wpstream_live_event_player_note';
495 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
496 - set_transient($transient_name, $event_status, 45);
497 - }
498 -
499 - $hls_playback_url = '';
500 - $live_conect_views = '';
501 -
502 - if(isset($event_status['status']) && $event_status['status']=='active'){
503 - //live event
504 - if(isset($event_status['hls_playback_url'])){
505 - $hls_playback_url = $event_status['hls_playback_url'];
506 -
507 - update_post_meta($channel_id,'stream_name',$event_status['stream_name']);
508 - update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']);
509 - delete_transient( 'free_event_streamName_'.$event_status['stream_name']);
510 -
403 + $chatUrl= get_post_meta($product_id,'statsUrl',true);
404 +
405 +
406 + $live_event_uri_final = $this->wpstream_request_hls_player_dynamic('',$product_id);// buleala lu Gabi
407 + $now = time().rand(0,10);
408 + $live_conect_array = explode('live.streamer.wpstream.net',$live_event_uri_final);
409 + $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
410 + $live_conect_views = $this->remove_http($live_conect_views);
411 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
412 + $autoplay = 'autoplay';
413 + if(intval($event_settings['autoplay'])==0){
414 + $autoplay='no_autoplay';
511 415 }
512 - $live_conect_views = $this->wpstream_get_live_connect_uri($event_status, 'hls_playback_url');
513 - if(isset($event_status['chat_url'])){
514 - $chat_url = $event_status['chat_url'];
515 - }
516 -
517 - }else{
518 - // event not live
519 - }
520 -
521 - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
522 - $autoplay=false;
523 - }
524 -
525 - $bootstrap_is_muted = ( isset( $event_settings['mute'] ) && intval( $event_settings['mute'] ) === 1 );
526 - $bootstrap_trailer_attachment_id = intval( get_post_meta( $channel_id, 'video_trailer', true ) );
527 - $bootstrap_trailer_url = '';
528 - if ( $bootstrap_trailer_attachment_id !== 0 ) {
529 - $bootstrap_trailer_url = wp_get_attachment_url( $bootstrap_trailer_attachment_id );
530 - }
531 - $live_content_uri = isset( $hls_playback_url ) ? trim( $hls_playback_url ) : '';
532 - $live_stats_uri = isset( $live_conect_views ) ? trim( $live_conect_views ) : '';
533 - $live_chat_uri = isset( $chat_url ) ? trim( $chat_url ) : '';
534 - $play_trailer_button_element_id = 'wpstream_live_video_play_trailer_btn_' . $now;
535 - $mute_trailer_button_element_id = 'wpstream_live_video_mute_trailer_btn_' . $now;
536 - $unmute_trailer_button_element_id = 'wpstream_live_video_unmute_trailer_btn_' . $now;
537 -
538 -
539 -
540 - $player_nonce = wp_create_nonce( 'wpstream_player_check_status_nonce' );
541 - echo '<div class="wpstream_live_player_wrapper function_wpstream_live_event_player" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$channel_id.'" id="wpstream_live_player_wrapper'.$now.'" data-nonce="' . $player_nonce . '" data-wpstream-bootstrap="live" data-instance-id="wpstream-live-'.esc_attr( $now ).'" data-video-element-id="'.esc_attr( $now ).'" data-title-overlay-element-id="'.esc_attr( $overlay_video_div_id ).'" data-content-url="'.esc_attr( $live_content_uri ).'" data-stats-uri="'.esc_attr( $live_stats_uri ).'" data-chat-url="'.esc_attr( $live_chat_uri ).'" data-trailer-url="'.esc_attr( $bootstrap_trailer_url ).'" data-autoplay="'. ( $autoplay ? '1' : '0' ) .'" data-muted="'. ( $bootstrap_is_muted ? '1' : '0' ) .'" data-play-trailer-button-element-id="'.esc_attr( $play_trailer_button_element_id ).'" data-mute-trailer-button-element-id="'.esc_attr( $mute_trailer_button_element_id ).'" data-unmute-trailer-button-element-id="'.esc_attr( $unmute_trailer_button_element_id ).'" > ';
416 +
417 + echo '<div class="wpstream_live_player_wrapper function_wpstream_live_event_player" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" id="wpstream_live_player_wrapper'.$now.'" > ';
418 +
419 + if(intval($event_settings['view_count'])==1){
420 + echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
421 + }
542 422
543 - $show_viewer_count = (
544 - ( isset($event_settings['view_count']) && intval($event_settings['view_count']) == 1 )
545 - || !isset($event_settings['view_count'])
546 - );
547 -
548 - echo '<div id="wpestream_live_counting" class="wpestream_live_counting" data-showviewercount="' . ($show_viewer_count ? '1' : '0') . '"></div>';
549 -
550 - $show_wpstream_not_live_mess=' style="display:none;" ';
551 - if(trim($hls_playback_url) ==''){
552 -
553 - $show_wpstream_not_live_mess='';
554 - }
555 -
556 - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ;
557 -
558 - if( function_exists('wpstream_theme_not_live_section' ) ) {
559 - print wpstream_theme_not_live_section( $channel_id );
560 - } else {
561 - print '<div class="wpstream_not_live_mess" '.$show_wpstream_not_live_mess.' style="display: none">
562 - <div class="wpstream_not_live_mess_back"></div>
563 - <div class="wpstream_not_live_mess_mess">'.esc_html($message_show).'</div>
564 - </div>';
565 - }
423 + $show_wpstream_not_live_mess=' style="display:none;" ';
424 + if(trim($live_event_uri_final) ==''){
425 + $show_wpstream_not_live_mess='';
426 + }
566 427
567 -
568 - $poster_data='';
569 - if(isset($thumb[0])){
570 - $poster_data=' poster="'.$thumb[0].'" ';
571 - }
572 - if($poster_show=='no'){
573 - $poster_data='';
574 - }
428 +
429 + print '<div class="wpstream_not_live_mess " '.$show_wpstream_not_live_mess.' ><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'.esc_html__('We are not live at this moment. Please check back later.','wpstream').'</div></div>';
430 +
431 +
432 + $poster_data=' poster="'.$thumb[0].'" ';
433 + if($poster_show=='no'){
434 + $poster_data='';
435 + }
436 +
437 + $is_muted='';
438 + if(intval($event_settings['mute'])==1){
439 + $is_muted=' muted ';
440 + }
441 +
442 +
443 +
444 + echo'
445 + <video id="wpstream-video'.$now.'" '.$poster_data.' class="video-js vjs-default-skin vjs-16-9 vjs-wpstream" playsinline="true" '.$is_muted.' controls data-autoplay='.$autoplay.'>
446 + <source
447 + src="'.$live_event_uri_final.'"
448 + type="application/x-mpegURL">
449 + </video>';
575 450
576 - $is_muted=false;
577 - if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
578 - $is_muted=true;
579 - }
580 - // override $is_muted and $autoplay here - for testing
581 - // $autoplay = true;
582 - // $is_muted = false;
583 -
584 - $autoplay_str = $autoplay ? 'autoplay' : '';
585 - $is_muted_str = $is_muted ? 'muted' : '';
586 -
587 - $video_trailer = '';
588 - $trailer_attachment_id = intval (get_post_meta( $channel_id, 'video_trailer', true ));
589 - $video_trailer = '';
590 - $video_trailer_type = '';
591 - $has_trailer_class = '';
592 - if($trailer_attachment_id!=0) {
593 - $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
594 - $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
595 - if( isset ($attachment_metadata['mime_type']) ) {
596 - $video_trailer_type = $attachment_metadata['mime_type'];
451 + print '<script type="text/javascript">
452 + //<![CDATA[
453 + jQuery(document).ready(function(){
454 + wpstream_player_initialize("'.$now.'","'.$live_event_uri_final.'","'.$live_conect_views.'","'.$autoplay.'");';
455 + print'});
456 + //]]>
457 + </script>';
458 + print '</div>';
459 +
460 +
461 + if(trim($live_event_uri_final) ==''){
462 + // $show_wpstream_not_live_mess='';
463 + }else{
464 + print '<script type="text/javascript">
465 + //<![CDATA[
466 + jQuery(document).ready(function(){
467 + var player_wrapper = jQuery(".wpstream_live_player_wrapper");
468 + wpstream_read_websocket_info("'.$product_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chatUrl.'", "'.$live_event_uri_final.'");
469 + });
470 + //]]>
471 + </script>';
597 472 }
598 - $poster_data=''; // cancel poster for theme
599 - $has_trailer_class='wpstream_theme_player_has_trailer';
600 - }
473 +
474 +
475 + if($use_chat=="yes"){
476 + $this->wpstream_connect_to_chat($product_id);
477 + }
478 +
479 + usleep (10000);
601 480
602 - // override trailer url here - for testing
603 - // $video_trailer = '';
604 - // $video_trailer = '/wp-content/uploads/2023/10/production-ID_4608975.mp4';
605 - // $video_trailer = '/wp-content/uploads/2023/10/ultrawide.mp4';
481 + }
606 482
607 483
608 484
609 - $player_logo_position_data = $this->wpstream_get_player_logo_data( $channel_id );
610 - $player_logo_position = $player_logo_position_data['player_logo_position'];
611 - $player_logo_position_class = $player_logo_position_data['player_logo_position_class'];
612 - $player_logo_horizontal_position = $player_logo_position_data['player_logo_horizontal_position'];
613 -// echo'
614 -// <div class="wpstream-video-container">
615 -// <div id="wpstream-pre-load-spinner" class="wpstream-pre-load-spinner"></div>
616 -// <video id="wpstream-video'.$now.'" '.$poster_data.' class="video-js vjs-default-skin vjs-fluid vjs-wpstream ' . esc_attr($has_trailer_class) . ' ' . $player_theme . ' ' . $player_logo_position_class . ' ' . $player_logo_horizontal_position . '" playsinline="true" '.$is_muted_str." ".$autoplay_str.'>
617 -// </video>
618 -// </div>';
619 - echo '<div class="wpstream-pre-load-spinner"></div>';
620 - echo'
621 - <video id="wpstream-video'.$now.'" '.$poster_data.' class="video-js vjs-default-skin vjs-fluid vjs-wpstream ' . esc_attr($has_trailer_class) . ' ' . $player_theme . ' ' . $player_logo_position_class . ' ' . $player_logo_horizontal_position . '" playsinline="true" '.$is_muted_str." ".$autoplay_str.'>
622 -
623 - </video>';
624 - if ($video_trailer){
625 - print '<div class="wpstream_theme_trailer_wrapper">';
626 - print '<div id="' . esc_attr( $play_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_play_trailer">
627 - <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
628 - <path fill-rule="evenodd" clip-rule="evenodd" d="M26.6667 1.5H3.33337C2.50495 1.5 1.83337 2.17157 1.83337 3V21C1.83337 21.8284 2.50495 22.5 3.33338 22.5H26.6667C27.4951 22.5 28.1667 21.8284 28.1667 21V3C28.1667 2.17157 27.4951 1.5 26.6667 1.5ZM3.33337 0C1.67652 0 0.333374 1.34315 0.333374 3V21C0.333374 22.6569 1.67652 24 3.33338 24H26.6667C28.3236 24 29.6667 22.6569 29.6667 21V3C29.6667 1.34315 28.3236 0 26.6667 0H3.33337ZM4.83337 4C4.55723 4 4.33337 4.22386 4.33337 4.5V6.16667C4.33337 6.44281 4.55723 6.66667 4.83337 6.66667H6.50004C6.77618 6.66667 7.00004 6.44281 7.00004 6.16667V4.5C7.00004 4.22386 6.77618 4 6.50004 4H4.83337ZM23.5 4C23.2239 4 23 4.22386 23 4.5V6.16667C23 6.44281 23.2239 6.66667 23.5 6.66667H25.1667C25.4428 6.66667 25.6667 6.44281 25.6667 6.16667V4.5C25.6667 4.22386 25.4428 4 25.1667 4H23.5ZM4.33337 11.167C4.33337 10.8909 4.55723 10.667 4.83337 10.667H6.50004C6.77618 10.667 7.00004 10.8909 7.00004 11.167V12.8337C7.00004 13.1098 6.77618 13.3337 6.50004 13.3337H4.83337C4.55723 13.3337 4.33337 13.1098 4.33337 12.8337V11.167ZM23.5001 10.667C23.224 10.667 23.0001 10.8909 23.0001 11.167V12.8337C23.0001 13.1098 23.224 13.3337 23.5001 13.3337H25.1668C25.4429 13.3337 25.6668 13.1098 25.6668 12.8337V11.167C25.6668 10.8909 25.4429 10.667 25.1668 10.667H23.5001ZM4.33337 17.833C4.33337 17.5569 4.55723 17.333 4.83337 17.333H6.50004C6.77618 17.333 7.00004 17.5569 7.00004 17.833V19.4997C7.00004 19.7758 6.77618 19.9997 6.50004 19.9997H4.83337C4.55723 19.9997 4.33337 19.7758 4.33337 19.4997V17.833ZM23.5001 17.333C23.224 17.333 23.0001 17.5569 23.0001 17.833V19.4997C23.0001 19.7758 23.224 19.9997 23.5001 19.9997H25.1668C25.4429 19.9997 25.6668 19.7758 25.6668 19.4997V17.833C25.6668 17.5569 25.4429 17.333 25.1668 17.333H23.5001ZM19.0677 13.0997L13.4077 16.5087C13.0434 16.7281 12.6092 16.7094 12.2661 16.5091C11.9218 16.3081 11.6666 15.9224 11.6666 15.4086V8.59072C11.6666 8.07698 11.9218 7.69125 12.2661 7.49026C12.6092 7.28999 13.0434 7.27126 13.4077 7.49064L19.0677 10.8996C19.8663 11.3805 19.8663 12.6188 19.0677 13.0997Z"/>
629 - </svg>
630 - '.esc_html__('Play Trailer', 'wpstream').'</div>';
631 - print '<div id="' . esc_attr( $mute_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_mute_trailer">
632 - <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
633 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.32143 10.0789H8.69499L18.8964 0L21.1428 0.921053V35.1316L18.8964 36L8.69499 25.8684H1.32143L0 24.5526V11.3947L1.32143 10.0789ZM10.175 23.6842L18.5 31.9474V4.10526L10.175 12.3158L9.24999 12.7105H2.64286V23.2368H9.24999L10.175 23.6842ZM37 17.9737C37.0069 22.2216 35.5329 26.3401 32.8295 29.6263L30.9478 27.7579C33.1613 24.9734 34.3629 21.5249 34.3571 17.9737C34.3571 14.2895 33.0885 10.8974 30.9637 8.21053L32.8454 6.34211C35.5382 9.62494 37.0062 13.735 37 17.9737ZM31.7143 17.9737C31.7193 20.8255 30.7895 23.6011 29.0661 25.8789L27.1738 23.9947C28.4127 22.2295 29.0752 20.1272 29.0714 17.9737C29.0751 15.8287 28.4174 13.7344 27.1871 11.9737L29.0793 10.0895C30.7338 12.2868 31.7143 15.0158 31.7143 17.9737ZM26.4286 17.9737C26.4286 19.4842 26.0057 20.8947 25.2657 22.0947L23.3126 20.1526C23.6249 19.4729 23.7876 18.7345 23.7899 17.9869C23.7922 17.2394 23.634 16.5001 23.3258 15.8184L25.2789 13.8737C26.0083 15.0684 26.4286 16.4737 26.4286 17.9737Z" fill="white"/>
634 - </svg>
635 -
636 - </div>';
637 - print '<div id="' . esc_attr( $unmute_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_unmute_trailer">
638 - <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
639 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.15625 8.85688H7.60813L16.5344 0L18.5 0.809375V30.8719L16.5344 31.635L7.60813 22.7319H1.15625L0 21.5756V10.0131L1.15625 8.85688ZM8.90313 20.8125L16.1875 28.0738V3.6075L8.90313 10.8225L8.09375 11.1694H2.3125V20.4194H8.09375L8.90313 20.8125ZM30.5967 11.3127L32.2316 12.9477L28.2287 16.9506L32.2316 20.9559L30.5967 22.5908L26.5938 18.5856L22.5885 22.5908L20.9536 20.9559L24.9588 16.9506L20.9513 12.95L22.5862 11.3151L26.5938 15.3157L30.5967 11.3127Z" fill="white"/>
640 - </svg>
641 - </div>';
642 - print '</div>';
643 - }
644 - print '</div>';
645 -
646 -
647 - // Live player bootstrap is handled by wpstream-player-bootstrap.js.
648 -
649 -
650 - if($use_chat=="yes"){
651 - $this->wpstream_connect_to_chat($channel_id);
652 - }
653 -
654 - usleep (10000);
655 -
656 - }
657 -
658 -
659 -
660 -
661 -
662 485 /**
663 - *
664 - * Edited in 4.0
665 - *
666 - *
667 486 * Live Event Player
668 487 *
669 488 * @author cretu
670 489 */
671 490
672 - function wpstream_live_event_player_low_latency($channel_id,$poster_show='',$use_chat=''){
673 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
674 - $thumb_id = get_post_thumbnail_id($channel_id);
491 + function wpstream_live_event_player_low_latency($product_id,$poster_show='',$use_chat=''){
492 + $event_settings = $this->wpestream_return_event_settings($product_id);
493 + $live_event_uri = get_post_meta($product_id,'live_event_uri',true);
494 + $api20_event_id = get_post_meta($product_id,'server_id',true);
495 +
496 + $thumb_id = get_post_thumbnail_id($product_id);
675 497 $thumb = wp_get_attachment_image_src($thumb_id,'small');
498 +
499 + $chatUrl= get_post_meta($product_id,'statsUrl',true);
676 500
677 - $event_settings = $this->wpestream_return_event_settings($channel_id);
678 - $notes = 'wpstream_live_event_player_low_latency_note';
679 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
680 - $hls_playback_url = '';
681 - $live_conect_views = '';
682 - $now = time().rand(0,10);
501 +
502 + //$live_event_uri_final = $this->wpstream_request_hls_player_dynamic('',$product_id);// buleala lu Gabi
683 503
684 504
685 -
686 - if(isset($event_status['status']) && $event_status['status']=='active'){
687 - //live event
688 - if(isset($event_status['sldp_playback_url'])){
689 - $hls_playback_url = $event_status['sldp_playback_url'];
505 + $live_event_uri_final= get_post_meta($product_id,'sldpPlaybackUrl',true);
506 + $now = time().rand(0,10);
507 +
508 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
690 509
691 - }
692 - $live_conect_views = $this->wpstream_get_live_connect_uri($event_status, 'sldp_playback_url');
693 - if(isset($event_status['chat_url'])){
694 - $chat_url =$event_status['chat_url'];
695 - }
696 -
697 - }else{
698 - // event not live
699 - }
700 510
511 +
701 512
702 -
703 -
704 - $low_latency_is_muted = ( isset($event_settings['mute']) && intval($event_settings['mute']) == 1 );
705 - $low_latency_autoplay = true;
706 - if ( isset($event_settings['autoplay']) && intval($event_settings['autoplay']) == 0 ) {
707 - $low_latency_autoplay = false;
708 - }
709 - $low_latency_content_uri = isset( $hls_playback_url ) ? trim( $hls_playback_url ) : '';
710 - $low_latency_chat_uri = isset( $chat_url ) ? trim( $chat_url ) : '';
711 - $low_latency_stats_uri = isset( $live_conect_views ) ? trim( $live_conect_views ) : '';
712 -
713 - echo '<div class="wpstream_live_player_wrapper function_wpstream_live_event_player_low_latency wpstream_low_latency" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$channel_id.'" id="wpstream_live_player_wrapper'.$now.'" data-instance-id="wpstream-live-low-latency-'.esc_attr( $now ).'" data-wpstream-bootstrap="live-low-latency" data-event-id="'.esc_attr( $channel_id ).'" data-video-element-id="wpstream-video'.esc_attr( $now ).'" data-content-url="'.esc_attr( $low_latency_content_uri ).'" data-chat-url="'.esc_attr( $low_latency_chat_uri ).'" data-stats-uri="'.esc_attr( $low_latency_stats_uri ).'" data-autoplay="'. ( $low_latency_autoplay ? '1' : '0' ) .'" data-muted="'. ( $low_latency_is_muted ? '1' : '0' ) .'" > ';
513 + echo '<div class="wpstream_live_player_wrapper function_wpstream_live_event_player_low_latency wpstream_low_latency" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" id="wpstream_live_player_wrapper'.$now.'" > ';
714 514
715 -
716 - if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){
515 + if(intval($event_settings['view_count'])==1){
717 516 echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
718 517 }
719 518
720 519 $show_wpstream_not_live_mess=' style="display:none;" ';
721 - if(trim($hls_playback_url) ==''){
520 + if(trim($live_event_uri_final) ==''){
722 521 $show_wpstream_not_live_mess='';
723 522 }
724 523
725 - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ;
726 - print '<div class="wpstream_not_live_mess " '.$show_wpstream_not_live_mess.' ><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'. $message_show.'</div></div>';
524 +
525 + print '<div class="wpstream_not_live_mess " '.$show_wpstream_not_live_mess.' ><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'.esc_html__('We are not live at this moment. Please check back later.','wpstream').'</div></div>';
727 526
728 527
729 528 $poster_data=' poster="'.$thumb[0].'" ';
730 529 if($poster_show=='no'){
@@ -732,16 +531,15 @@
732 531 }
733 532
734 533
735 534 $is_muted='';
736 - if( $low_latency_is_muted ){
737 - $is_muted=' muted ';
535 + if(intval($event_settings['mute'])==1){
536 + $is_muted='muted';
738 537 }
739 538
740 -
741 539 $autoplay='autoplay';
742 - if( !$low_latency_autoplay ){
743 - $autoplay='';
540 + if(intval($event_settings['autoplay'])==0){
541 + $autoplay='no_autoplay';
744 542 }
745 543
746 544 echo'
747 545 <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
@@ -746,13 +544,35 @@
746 544 echo'
747 545 <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
748 546 </div>';
749 547
750 - // Low-latency player bootstrap is handled by wpstream-player-bootstrap.js.
548 + print '<script type="text/javascript">
549 + //<![CDATA[
550 + jQuery(document).ready(function(){
551 + var low_latencyid="wpstream-video'.$now.'";
552 + document.addEventListener("DOMContentLoaded", initPlayer(low_latencyid, "'.$live_event_uri_final.'","'.$is_muted.'","'.$autoplay.'" ) ); ';
553 + print'});
554 + //]]>
555 + </script>';
556 +
751 557
752 558
559 + if(trim($live_event_uri_final) ==''){
560 + // $show_wpstream_not_live_mess='';
561 + }else{
562 + print '<script type="text/javascript">
563 + //<![CDATA[
564 + jQuery(document).ready(function(){
565 + var player_wrapper = jQuery(".wpstream_live_player_wrapper");
566 + wpstream_read_websocket_info("'.$product_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chatUrl.'", "'.$live_event_uri_final.'");
567 + });
568 + //]]>
569 + </script>';
570 + }
571 +
572 +
753 573 if($use_chat=="yes"){
754 - $this->wpstream_connect_to_chat($channel_id);
574 + $this->wpstream_connect_to_chat($product_id);
755 575 }
756 576
757 577 usleep (10000);
758 578
@@ -759,152 +579,128 @@
759 579 }
760 580
761 581
762 582
763 -
764 -
765 - /*
766 - *
767 - * Request HLS player
768 - *
769 - *
770 - *
583 + /**
584 + * HLS PLAYER
585 + *
586 + * @author cretu
771 587 */
772 - public function wpstream_request_video_on_demand_hls_player($video_name,$product_id){
773 - if($video_name==''){
774 - return '';
775 - }
776 -
777 - $transient_name = 'wpstream_video_on_demand_'.$video_name;
778 - $hls_to_return = get_transient( $transient_name );
779 - $hls_to_return = false;
588 + public function wpstream_request_hls_player_dynamic($server_id,$product_id){
589 +
590 + $transient_name = 'hls_to_return_'.$product_id;
591 + $hls_to_return = get_transient( $transient_name );
780 592
781 -
782 - if($hls_to_return==false){
783 -
784 - $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
785 - $url = 'video/info';
593 + if ( false === $hls_to_return || $hls_to_return=='' ) { //ws || $hls_to_return==''
594 +
595 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
596 + $values_array = array();
597 + $values_array['server_id'] = $server_id;
598 +
599 + if($server_id==''){
600 + $this->main->wpstream_live_connection->wpstream_check_event_status_front_player($product_id,$server_id);
601 + $server_id = get_post_meta($product_id,'server_id', true );
602 + $values_array['server_id'] = $server_id;
603 + }
786 604
787 - //corsorigin de check
788 - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
789 - $domain = parse_url ( get_site_url() );
790 - $domain_scheme = 'http';
791 - if(is_ssl()){
792 - $domain_scheme='https';
605 +
606 + if($server_id==''){
607 + delete_transient($transient_name);
608 + return '';exit();
793 609 }
610 +
611 + $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/ap20_get_player_hls_dynamic/?access_token=".$token;
794 612
795 -
796 - $wpstream_vod_domain_lock = intval( get_option('wpstream_vod_domain_lock','') ) ;
797 - $corsorigin='*';
798 - if($wpstream_vod_domain_lock !== 0 ){
799 - $corsorigin=$domain_scheme.'://'.$domain['host'];
800 - }
801 613
802 -
803 - $is_encrypt="false";
804 - $wpstream_vod_encrypt = intval( get_option('wpstream_vod_encrypt','') ) ;
805 - if( intval( $wpstream_vod_encrypt ) ==1 ){
806 - $is_encrypt="true";
614 + $arguments = array(
615 + 'method' => 'GET',
616 + 'timeout' => 45,
617 + 'redirection' => 5,
618 + 'httpversion' => '1.0',
619 + 'blocking' => true,
620 + 'headers' => array(),
621 + 'body' => $values_array,
622 + 'cookies' => array()
623 + );
624 + $response = wp_remote_post($url,$arguments);
625 +
626 + $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
627 +
628 +
629 +
630 +
631 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
632 + $hls_to_return = trim($received_data);
633 +
634 +
635 + set_transient( $transient_name, $hls_to_return, 60 );
636 + return $hls_to_return;
637 + }else{
638 + return 'failed connection';
807 639 }
640 + exit();
641 + }else{
642 + return $hls_to_return;
643 + }
808 644
809 - $hlsKeysUrlPrefix = get_site_url().'?wpstream_voddrm=';
810 - $encrypt = $is_encrypt;
811 - $debugDrm = false;
645 + }
812 646
813 - $curl_post_fields=array(
814 - 'access_token' => $access_token,
815 - 'name' => $video_name,
816 - 'corsOrigin' => $corsorigin,
817 - 'encryptHls' => $encrypt,
818 - 'hlsKeysUrlPrefix' => $hlsKeysUrlPrefix,
819 - 'debugDrm' => $debugDrm,
820 - 'embed' => true,
821 - );
822 647
823 -
824 - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
825 - $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
826 648
827 - if($curl_response_decoded['success']){
828 - set_transient( $transient_name, $curl_response_decoded['hlsUrl'] ,300);
829 - $hls_to_return = $curl_response_decoded['hlsUrl'];
830 - if( isset($curl_response_decoded['hlsDecryptionKey']) && isset($curl_response_decoded['hlsDecryptionKeyIndex']) ){
831 - update_post_meta($product_id,'hlsDecryptionKey',$curl_response_decoded['hlsDecryptionKey']);
832 - update_post_meta($product_id,'hlsDecryptionKeyIndex',$curl_response_decoded['hlsDecryptionKeyIndex']);
833 - }else{
834 - delete_post_meta($product_id,'hlsDecryptionKey');
835 - delete_post_meta($product_id,'hlsDecryptionKeyIndex');
836 - }
649 + /**
650 + * HLS PLAYER
651 + *
652 + * @author cretu
653 + */
654 +
837 655
838 - if ( isset( $curl_response_decoded['video'] ) &&
839 - isset( $curl_response_decoded['embedKey'] ) &&
840 - isset( $curl_response_decoded['embedUrl'] )
841 - ) {
842 - update_post_meta( $product_id, 'wpstream_vod_video_data', trim( (string) $curl_response_decoded['video'] ) );
843 - update_post_meta( $product_id, 'wpstream_vod_embed_key', trim( (string) $curl_response_decoded['embedKey'] ) );
844 - update_post_meta( $product_id, 'wpstream_vod_embed_url', trim( (string) $curl_response_decoded['embedUrl'] ) );
845 - }
656 + public function wpstream_request_hls_player($product_id){
657 +
658 + $transient_name = 'hls_to_return_'.$product_id;
659 + $hls_to_return = get_transient( $transient_name );
846 660
847 - if ( isset( $curl_response_decoded['wpstreamPlayerEnabled'] ) ) {
848 - update_post_meta( $product_id, 'wpstream_player_enabled', intval( $curl_response_decoded['wpstreamPlayerEnabled'] ) );
849 - }
850 - }else{
851 - return '';
852 - }
853 -
854 - }
855 -
856 - return $hls_to_return;
857 -
858 - }
661 + if ( false === $hls_to_return || $hls_to_return=='' ) {
662 +
663 + $show_id = intval($product_id);
664 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
665 + $values_array = array();
666 + $values_array['show_id'] = $show_id;
859 667
860 - function wpstream_get_player_theme( $channel_id = null ) {
861 - $player_theme = get_option('wpstream_video_player_theme');
862 - $is_streamify_user = $this->wpstream_is_streamify_user( $channel_id );
863 - if ( !empty($player_theme) && !$is_streamify_user ) {
864 - $this->wpstream_enqueue_player_theme_style( $player_theme );
865 - return 'vjs-theme-' . $player_theme;
866 - }
668 + $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/videos/ap20_get_player_hls/?access_token=".$token;
867 669
868 - return '';
869 - }
870 670
871 - function wpstream_enqueue_player_theme_style( $player_theme ) {
872 - if ( $player_theme != 'default' ) {
873 - wp_enqueue_style('videojs-theme-' . $player_theme, 'https://cdn.jsdelivr.net/npm/@videojs/themes@1/dist/' . $player_theme . '/index.min.css', array(), '1.0.0');
671 + $arguments = array(
672 + 'method' => 'GET',
673 + 'timeout' => 45,
674 + 'redirection' => 5,
675 + 'httpversion' => '1.0',
676 + 'blocking' => true,
677 + 'headers' => array(),
678 + 'body' => $values_array,
679 + 'cookies' => array()
680 + );
681 + $response = wp_remote_post($url,$arguments);
682 +
683 + $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
874 684
875 - }
876 - }
685 +
686 +
687 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
688 + $hls_to_return = trim($received_data);
689 + set_transient( $transient_name, $hls_to_return, 60 );
690 + return $hls_to_return = trim($received_data);
691 + }else{
692 + return 'failed connection';
693 + }
694 + exit();
695 + }else{
696 + return $hls_to_return;
697 + }
877 698
878 - /*
879 - * Return data about the logo
880 - */
881 - private function wpstream_get_player_logo_data( $product_id ): array {
882 - $player_logo_position = get_option( 'wpstream_player_logo_position', 'top-right' );
883 - $player_logo_position_class = '';
884 - $player_logo_horizontal_position = '';
885 - if ( $player_logo_position && $player_logo_position != '' ) {
886 - $player_logo_position_parts = explode( '-', $player_logo_position );
887 - if ( isset( $player_logo_position_parts[0], $player_logo_position_parts[1] ) ) {
888 - $player_logo_position_class = 'logo-' . $player_logo_position_parts[0];
889 - $player_logo_horizontal_position = 'logo-' . $player_logo_position_parts[1];
890 - }
891 - }
699 + }
892 700
893 - $player_logo_src = $this->wpstream_get_video_player_logo( $product_id );
894 - $player_logo_opacity = intval( esc_html( get_option('wpstream_player_logo_opacity','100') ) ) / 100;
895 701
896 - return array(
897 - 'player_logo_src' => $player_logo_src,
898 - 'player_logo_position' => $player_logo_position,
899 - 'player_logo_position_class' => $player_logo_position_class,
900 - 'player_logo_horizontal_position' => $player_logo_horizontal_position,
901 - 'player_logo_opacity' => $player_logo_opacity,
902 - );
903 - }
904 702
905 -
906 -
907 703 /**
908 704 * VODPlayer uri details
909 705 *
910 706 * @author cretu
@@ -917,30 +713,38 @@
917 713 * 1 - free live channel
918 714 * 2 - free video encrypted
919 715 * 3 - free video -not encrypted
920 716 */
921 -
922 - $post_type = get_post_type($product_id);
923 717 $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
924 - $video_path_final = '';
925 - $video_type = '';
926 - if( ( $post_type =='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
718 +
719 +
720 + if($free_video_type==2 || get_post_type($product_id)=='product' ){
927 721
928 - /*
929 - * IF vide is encrypted- readed from vod,streaner
930 - *
931 - */
932 -
722 + /* IF vide is encrypted- readed from vod,streaner
723 + */
933 724
934 725 $video_type = 'application/x-mpegURL';
935 726 $video_path = get_post_meta($product_id,'_movie_url',true);
936 - if(get_post_type($product_id)=='wpstream_product_vod'){
727 + if(get_post_type($product_id)=='wpstream_product'){
937 728 $video_path = esc_html(get_post_meta($product_id, 'wpstream_free_video', true));
938 729 }
939 - $video_path_final = $this->wpstream_request_video_on_demand_hls_player($video_path,$product_id);
940 730
731 + $username = esc_html ( get_option('wpstream_api_username','') );
732 + if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
733 + $username = $this->wpstream_retrive_username();
734 + }
735 +
736 + if(strpos($username,'@')!=false){
737 + $username_array= explode('@', $username);
738 + $username=$username_array[0];
739 + }
740 +
741 + $video_path_final = 'https://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
742 + if(!is_ssl()){
743 + $video_path_final = 'http://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
744 + }
941 745
942 - }else if( $post_type =='wpstream_product_vod' && $free_video_type==3 ){
746 + }else if($free_video_type==3){
943 747
944 748 /* Video is unecrypted - read from local or youtube / vimeo
945 749 */
946 750
@@ -945,17 +749,24 @@
945 749 */
946 750
947 751 $video_type = 'video/mp4';
948 752 $video_path_final=esc_html(get_post_meta($product_id, 'wpstream_free_video_external', true));
949 - wp_enqueue_script('youtube.min');
753 +
754 + if (strpos($video_path_final, 'www.youtube') !== false) {
755 + $wpstream_data_setup= ' data-setup=\'{ "techOrder": ["youtube"], "sources": [{ "type": "video/youtube", "src": "'.$video_path_final.'"}] }\' ';
756 + $video_path_final='';
757 + }
758 + if (strpos($video_path_final, 'vimeo.com') !== false) {
759 + $wpstream_data_setup= ' data-setup=\'{"techOrder": ["vimeo"], "sources": [{ "type": "video/vimeo", "src": "'.$video_path_final.'"}], "vimeo": { "color": "#fbc51b"} }\' ';
760 + $video_path_final='';
761 + }
762 +
950 763 }
951 764
952 - $return_array = array();
765 + $return_array=array();
953 766 $return_array['video_path_final'] = $video_path_final;
954 767 $return_array['wpstream_data_setup']= $wpstream_data_setup;
955 768 $return_array['video_type'] = $video_type;
956 - $return_array['free_video_type'] = $free_video_type;
957 - $return_array['post_type'] = $post_type ;
958 769 return $return_array;
959 770 }
960 771
961 772
@@ -966,654 +777,92 @@
966 777 * @author cretu
967 778 */
968 779
969 780 public function wpstream_video_on_demand_player($product_id){
970 - wp_enqueue_script('video.min');
971 - wp_enqueue_script('wpstream-player');
972 - wp_enqueue_script('wpstream-player-controls');
781 +
782 + $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id);
783 + $video_path_final = $uri_details['video_path_final'];
784 + $wpstream_data_setup = $uri_details['wpstream_data_setup'];
785 + $video_type = $uri_details['video_type'];
786 +
787 + $thumb_id = get_post_thumbnail_id($product_id);
788 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
789 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
790 +
791 + $pack = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
792 +
793 + if(isset($pack['band']) && $pack['band']>0){
794 + echo '<video id="wpstream-video'.time().'" class="video-js vjs-default-skin vjs-16-9 kuk wpstream_video_on_demand vjs-wpstream" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" controls preload="auto"
795 + poster="'.$thumb[0].'" '.$wpstream_data_setup.'>
973 796
974 - $player_theme = $this->wpstream_get_player_theme( $product_id );
975 -
976 - $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id);
977 - $video_path_final = $uri_details['video_path_final'];
978 - $wpstream_data_setup = $uri_details['wpstream_data_setup'];
979 - $video_type = $uri_details['video_type'];
980 - $now = time().rand(0,1000000);
981 -
982 - $overlay_video_div_id = "random_id_".$now;
983 - $this->wpstream_render_vod_title_overlay(
984 - $overlay_video_div_id,
985 - get_the_title($product_id)
986 - );
987 -
988 - $thumb_id = get_post_thumbnail_id($product_id);
989 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
990 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
991 -
992 - $poster_thumb = '';
993 - if(isset($thumb[0])){
994 - $poster_thumb=$thumb[0];
995 - }
996 -
997 - $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true);
998 - $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true);
999 -
1000 -
1001 - $pack = $this->main->quota_manager->get_live_quota_data( 'wpstream_video_on_demand_player' );
1002 -
1003 -
1004 -
1005 - $trailer_attachment_id = intval (get_post_meta( $product_id, 'video_trailer', true ));
1006 - $video_trailer = '';
1007 - $video_trailer_type = '';
1008 - if($trailer_attachment_id!=0) {
1009 - $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
1010 - $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
1011 - if( isset ($attachment_metadata['mime_type']) ) {
1012 - $video_trailer_type = $attachment_metadata['mime_type'];
1013 - }
1014 - }
1015 -
1016 - // override trailer setup here (for testing)
1017 - // $trailer_attachment_id = 1;
1018 - // $video_trailer = '/wp-content/uploads/2023/10/production-ID_4608975.mp4';
1019 - // $video_trailer = '/wp-content/uploads/2023/10/ultrawide.mp4';
1020 -
1021 - // If the video is self hosted or external, we should let the user see it
1022 - $video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
1023 -
1024 -
1025 - if ( (isset($pack['available_data_mb']) && $pack['available_data_mb']>0) || $video_type === 3 ) {
1026 -
1027 - if($video_path_final==''){
1028 - if( $uri_details['post_type']=='wpstream_product_vod' && $uri_details['free_video_type']==3 ){
797 + <source src="'.trim($video_path_final).'" type="'.$video_type.'">
798 + <p class="vjs-no-js">
799 + To view this video please enable JavaScript, and consider upgrading to a web browser that
800 + <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
801 + </p>
802 + </video>';
1029 803 }else{
1030 - print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>';
804 + print esc_html_e('Insufficient resources to stream this title','wpstream');
1031 805 }
1032 806
1033 - }
1034 -
1035 - // TODO (crerem) populate these from VOD settings
1036 - $autoplay = false;
1037 - $muted = false;
1038 -
1039 - $wpstream_vod_start_muted = intval ( get_option('wpstream_vod_start_muted','') );
1040 - if($wpstream_vod_start_muted===1){
1041 - $muted=true;
1042 - }
1043 - $wpstream_vod_autoplay = intval ( get_option('wpstream_vod_autoplay','') );
1044 - if($wpstream_vod_autoplay===1){
1045 - $autoplay=true;
1046 - }
1047 -
1048 - $poster_data = 'poster="'.esc_url($poster_thumb).'"';
1049 - $has_trailer_class='';
1050 - if($trailer_attachment_id !=0){
1051 - $poster_data=''; // cancel poster for theme
1052 - $has_trailer_class='wpstream_theme_player_has_trailer';
1053 - }
1054 -
1055 - $player_logo_data = $this->wpstream_get_player_logo_data( $product_id );
1056 - $player_logo_image = $player_logo_data['player_logo_src'];
1057 - $player_logo_position = $player_logo_data['player_logo_position'];
1058 - $player_logo_position_class = $player_logo_data['player_logo_position_class'];
1059 - $player_logo_horizontal_position = $player_logo_data['player_logo_horizontal_position'];
1060 - $player_logo_opacity = $player_logo_data['player_logo_opacity'];
1061 -
1062 - $captionsUrl = get_post_meta( $product_id, 'wpstream_closed_captions_file', true );
1063 - $play_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_play_trailer_btn_' . $now : '';
1064 - $mute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_mute_trailer_btn_' . $now : '';
1065 - $unmute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_unmute_trailer_btn_' . $now : '';
1066 - $play_video_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_play_video_btn_' . $now : '';
1067 -
1068 - $wpstream_vod_encrypt = intval( get_option( 'wpstream_vod_encrypt', '' ) );
1069 - $wpstream_vod_lock_to_website = intval( get_option( 'wpstream_vod_domain_lock', '' ) );
1070 -
1071 - $wpstream_session_encryption = 0;
1072 - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
1073 - if(isset($local_event_options['ses_encrypt']) && intval($local_event_options['ses_encrypt'])==1 ) {
1074 - $wpstream_session_encryption = 1;
1075 - }
1076 -
1077 - /**
1078 - * Presence bootstrap expects validatePlaybackSessionUrl as an absolute HTTP(S) URL that returns JSON { success: true } when the playback session is valid — not the literals "true"/"false".
1079 - * Embed keys must be minted with the same inputs as the iframe query (video, validatePlaybackSessionUrl, embedAncestor, encrypt) per player embed-key.js.
1080 - *
1081 - * @see WPStream player embed-key.js and session-validation.js (verifyPlaybackSessionUrl).
1082 - */
1083 - $vod_validate_url = '';
1084 - if ( $wpstream_session_encryption ) {
1085 - $vod_validate_url = esc_url_raw( apply_filters( 'wpstream_vod_validate_playback_session_url', $this->playback_session->wpstream_get_default_vod_validate_playback_session_url(), $product_id ) );
1086 - wp_localize_script(
1087 - 'wpstream-player-controls',
1088 - 'wpstreamVodIframeSessionApi',
1089 - array(
1090 - 'requirePlaybackSession' => true,
1091 - 'nonce' => wp_create_nonce( 'wpstream_playback_session_issue' ),
1092 - 'productId' => (int) $product_id,
1093 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
1094 - )
1095 - );
1096 - }
1097 -
1098 - $vod_embed_ancestor = '';
1099 - if ( $wpstream_vod_lock_to_website ) {
1100 - $vod_embed_ancestor = esc_url_raw(
1101 - apply_filters(
1102 - 'wpstream_vod_embed_ancestor',
1103 - $this->wpstream_get_site_origin_for_embed(),
1104 - $product_id
1105 - )
1106 - );
1107 - }
1108 -
1109 - // if there's "wpstream_vod_embed_url" set, it means that we use the new player
1110 - $wpstream_vod_embed_url = get_post_meta( $product_id, 'wpstream_vod_embed_url', true );
1111 -
1112 - $vod_iframe_base = WPSTREAM_PLAYER . "/player/vod?";
1113 - $vod_iframe_video_raw = (string) get_post_meta( $product_id, 'wpstream_vod_video_data', true );
1114 - $vod_iframe_video = trim( $vod_iframe_video_raw );
1115 - if ( strlen( $vod_iframe_video ) >= 2 ) {
1116 - $first_char = $vod_iframe_video[0];
1117 - $last_char = substr( $vod_iframe_video, -1 );
1118 - $is_wrapped_in_double_quotes = '"' === $first_char && '"' === $last_char;
1119 - $is_wrapped_in_single_quotes = "'" === $first_char && "'" === $last_char;
1120 - if ( $is_wrapped_in_double_quotes || $is_wrapped_in_single_quotes ) {
1121 - $vod_iframe_video = substr( $vod_iframe_video, 1, -1 );
1122 - }
1123 - }
1124 - $vod_iframe_embed_key = $this->wpstream_generate_player_embed_key(
1125 - $vod_iframe_video,
1126 - $vod_validate_url,
1127 - $vod_embed_ancestor,
1128 - $wpstream_vod_encrypt ? 'yes' : ''
1129 - );
1130 - if ( '' === $vod_iframe_embed_key ) {
1131 - $vod_iframe_embed_key = (string) get_post_meta( $product_id, 'wpstream_vod_embed_key', true );
1132 - }
1133 - $vod_iframe_trailer_embed_key = $this->wpstream_generate_player_embed_key(
1134 - $video_trailer,
1135 - $vod_validate_url,
1136 - $vod_embed_ancestor,
1137 - $wpstream_vod_encrypt ? 'yes' : ''
1138 - );
1139 -
1140 - $vod_poster_image = get_the_post_thumbnail_url( $product_id, 'full' );
1141 - $current_active_theme = wp_get_theme();
1142 -
1143 - $vod_iframe_skin_slug = '';
1144 - if ( preg_match( '/^vjs-theme-(city|fantasy|forest|sea)$/', $player_theme, $vod_iframe_skin_m ) ) {
1145 - $vod_iframe_skin_slug = $vod_iframe_skin_m[1];
1146 - }
1147 -
1148 - $vod_iframe_query_args = array_filter(
1149 - array(
1150 - 'video' => $vod_iframe_video,
1151 - 'posterImage' => $vod_poster_image,
1152 - 'embedKey' => $vod_iframe_embed_key,
1153 - 'autoplay' => $autoplay ? '1' : '',
1154 - 'skin' => $vod_iframe_skin_slug,
1155 - 'encrypt' => $wpstream_vod_encrypt ? 'yes' : '',
1156 - 'validatePlaybackSessionUrl' => $vod_validate_url,
1157 - 'embedAncestor' => $vod_embed_ancestor,
1158 - 'logoImage' => $player_logo_image,
1159 - 'logoPosition' => $player_logo_image ? $player_logo_position : '',
1160 - 'logoOpacity' => $player_logo_image ? $player_logo_opacity : '',
1161 - 'isThemeActive' => $current_active_theme->get('Name') === 'Hello WPStream',
1162 - ),
1163 - static function ( $v ) {
1164 - return $v !== null && $v !== '';
1165 - }
1166 - );
1167 -
1168 - $vod_trailer_iframe_query_args = array_filter(
1169 - array(
1170 - 'video' => $video_trailer,
1171 - 'embedKey' => $vod_iframe_trailer_embed_key,
1172 - 'skin' => $vod_iframe_skin_slug,
1173 - 'encrypt' => $wpstream_vod_encrypt ? 'yes' : '',
1174 - 'validatePlaybackSessionUrl' => $vod_validate_url,
1175 - 'embedAncestor' => $vod_embed_ancestor,
1176 - ),
1177 - static function ( $v ) {
1178 - return $v !== null && $v !== '';
1179 - }
1180 - );
1181 -
1182 - if ( $wpstream_vod_embed_url ) {
1183 - echo '<div class="wpstream_player_iframe_wrap">';
1184 - echo '<iframe id="playerFrame"
1185 - class="wpstream_video_on_demand_iframe"
1186 - title="' . esc_attr__( 'Embedded content', 'wpstream' ) . '"
1187 - src="' . esc_url( add_query_arg( $vod_iframe_query_args, $vod_iframe_base ) ) . '"
1188 - data-wpstream-frame-role="content"
1189 - allowfullscreen
1190 - allow="autoplay; fullscreen">
1191 - </iframe>';
1192 - if ( $trailer_attachment_id != 0 ) {
1193 - echo '<iframe id="playerFrameTrailer"
1194 - class="wpstream_video_on_demand_iframe wpstream_video_on_demand_iframe_trailer"
1195 - title="' . esc_attr__( 'Embedded trailer content', 'wpstream' ) . '"
1196 - src="' . esc_url( add_query_arg( $vod_trailer_iframe_query_args, $vod_iframe_base ) ) . '"
1197 - data-wpstream-frame-role="trailer"
1198 - allowfullscreen
1199 - allow="autoplay; fullscreen"
1200 - style="display:none;"
1201 - aria-hidden="true"
1202 - tabindex="-1">
1203 - </iframe>';
1204 - }
1205 - echo '</div>';
1206 - echo '<div class="wpstream_video_on_demand_actions_wrapper" data-trailer-muted-default="' . ( $muted ? '1' : '0' ) . '"' . ( $autoplay && $trailer_attachment_id !== 0 ? ' data-autoplay-trailer="1"' : '' ) . '>';
1207 - echo '<button type="button" class="wpstream_player_controls wpstream_video_on_demand_play_video_wrapper" aria-label="' . esc_attr__( 'Play Video', 'wpstream' ) . '">
1208 - <span class="wpstream_video_on_demand_play_video">
1209 - <svg width="29" height="30" viewBox="0 0 29 30" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
1210 - <path fill-rule="evenodd" clip-rule="evenodd" d="M6.1808 28.9035L26.274 18.1652C29.1087 16.6503 29.1087 12.7497 26.274 11.2348L6.1808 0.496557C4.88769 -0.194506 3.34623 -0.1355 2.1283 0.495357C0.906043 1.12846 1.0095e-06 2.34351 9.38766e-07 3.96179L0 25.4382C-7.07369e-08 27.0565 0.906042 28.2715 2.1283 28.9046C3.34622 29.5355 4.88769 29.5945 6.1808 28.9035ZM24.8221 13.8026C25.5742 14.2045 25.5742 15.1955 24.8221 15.5974L4.72891 26.3356C3.94628 26.7539 3.01386 26.2165 3.01386 25.4382L3.01386 3.96179C3.01386 3.18347 3.94628 2.6461 4.72891 3.06436L24.8221 13.8026Z" fill="#F1F1F1"></path>
1211 - </svg>
1212 - </span>
1213 - ' . esc_html__( 'Play Video', 'wpstream' ) . '
1214 - </button>';
1215 - if ( $trailer_attachment_id !== 0 ) {
1216 - echo '<button type="button" class="wpstream_player_controls wpstream_video_on_demand_play_trailer" aria-label="' . esc_attr__( 'Play Trailer', 'wpstream' ) . '">
1217 - <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
1218 - <path fill-rule="evenodd" clip-rule="evenodd" d="M26.6667 1.5H3.33337C2.50495 1.5 1.83337 2.17157 1.83337 3V21C1.83337 21.8284 2.50495 22.5 3.33338 22.5H26.6667C27.4951 22.5 28.1667 21.8284 28.1667 21V3C28.1667 2.17157 27.4951 1.5 26.6667 1.5ZM3.33337 0C1.67652 0 0.333374 1.34315 0.333374 3V21C0.333374 22.6569 1.67652 24 3.33338 24H26.6667C28.3236 24 29.6667 22.6569 29.6667 21V3C29.6667 1.34315 28.3236 0 26.6667 0H3.33337ZM4.83337 4C4.55723 4 4.33337 4.22386 4.33337 4.5V6.16667C4.33337 6.44281 4.55723 6.66667 4.83337 6.66667H6.50004C6.77618 6.66667 7.00004 6.44281 7.00004 6.16667V4.5C7.00004 4.22386 6.77618 4 6.50004 4H4.83337ZM23.5 4C23.2239 4 23 4.22386 23 4.5V6.16667C23 6.44281 23.2239 6.66667 23.5 6.66667H25.1667C25.4428 6.66667 25.6667 6.44281 25.6667 6.16667V4.5C25.6667 4.22386 25.4428 4 25.1667 4H23.5ZM4.33337 11.167C4.33337 10.8909 4.55723 10.667 4.83337 10.667H6.50004C6.77618 10.667 7.00004 10.8909 7.00004 11.167V12.8337C7.00004 13.1098 6.77618 13.3337 6.50004 13.3337H4.83337C4.55723 13.3337 4.33337 13.1098 4.33337 12.8337V11.167ZM23.5001 10.667C23.224 10.667 23.0001 10.8909 23.0001 11.167V12.8337C23.0001 13.1098 23.224 13.3337 23.5001 13.3337H25.1668C25.4429 13.3337 25.6668 13.1098 25.6668 12.8337V11.167C25.6668 10.8909 25.4429 10.667 25.1668 10.667H23.5001ZM4.33337 17.833C4.33337 17.5569 4.55723 17.333 4.83337 17.333H6.50004C6.77618 17.333 7.00004 17.5569 7.00004 17.833V19.4997C7.00004 19.7758 6.77618 19.9997 6.50004 19.9997H4.83337C4.55723 19.9997 4.33337 19.7758 4.33337 19.4997V17.833ZM23.5001 17.333C23.224 17.333 23.0001 17.5569 23.0001 17.833V19.4997C23.0001 19.7758 23.224 19.9997 23.5001 19.9997H25.1668C25.4429 19.9997 25.6668 19.7758 25.6668 19.4997V17.833C25.6668 17.5569 25.4429 17.333 25.1668 17.333H23.5001ZM19.0677 13.0997L13.4077 16.5087C13.0434 16.7281 12.6092 16.7094 12.2661 16.5091C11.9218 16.3081 11.6666 15.9224 11.6666 15.4086V8.59072C11.6666 8.07698 11.9218 7.69125 12.2661 7.49026C12.6092 7.28999 13.0434 7.27126 13.4077 7.49064L19.0677 10.8996C19.8663 11.3805 19.8663 12.6188 19.0677 13.0997Z"/>
1219 - </svg>
1220 - ' . esc_html__( 'Play Trailer', 'wpstream' ) . '
1221 - </button>';
1222 - echo '<div id="' . esc_attr( $mute_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_mute_trailer">
1223 - <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
1224 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.32143 10.0789H8.69499L18.8964 0L21.1428 0.921053V35.1316L18.8964 36L8.69499 25.8684H1.32143L0 24.5526V11.3947L1.32143 10.0789ZM10.175 23.6842L18.5 31.9474V4.10526L10.175 12.3158L9.24999 12.7105H2.64286V23.2368H9.24999L10.175 23.6842ZM37 17.9737C37.0069 22.2216 35.5329 26.3401 32.8295 29.6263L30.9478 27.7579C33.1613 24.9734 34.3629 21.5249 34.3571 17.9737C34.3571 14.2895 33.0885 10.8974 30.9637 8.21053L32.8454 6.34211C35.5382 9.62494 37.0062 13.735 37 17.9737ZM31.7143 17.9737C31.7193 20.8255 30.7895 23.6011 29.0661 25.8789L27.1738 23.9947C28.4127 22.2295 29.0752 20.1272 29.0714 17.9737C29.0751 15.8287 28.4174 13.7344 27.1871 11.9737L29.0793 10.0895C30.7338 12.2868 31.7143 15.0158 31.7143 17.9737ZM26.4286 17.9737C26.4286 19.4842 26.0057 20.8947 25.2657 22.0947L23.3126 20.1526C23.6249 19.4729 23.7876 18.7345 23.7899 17.9869C23.7922 17.2394 23.634 16.5001 23.3258 15.8184L25.2789 13.8737C26.0083 15.0684 26.4286 16.4737 26.4286 17.9737Z" fill="white"/>
1225 - </svg>
1226 - </div>';
1227 - echo '<div id="' . esc_attr( $unmute_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_unmute_trailer">
1228 - <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
1229 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.15625 8.85688H7.60813L16.5344 0L18.5 0.809375V30.8719L16.5344 31.635L7.60813 22.7319H1.15625L0 21.5756V10.0131L1.15625 8.85688ZM8.90313 20.8125L16.1875 28.0738V3.6075L8.90313 10.8225L8.09375 11.1694H2.3125V20.4194H8.09375L8.90313 20.8125ZM30.5967 11.3127L32.2316 12.9477L28.2287 16.9506L32.2316 20.9559L30.5967 22.5908L26.5938 18.5856L22.5885 22.5908L20.9536 20.9559L24.9588 16.9506L20.9513 12.95L22.5862 11.3151L26.5938 15.3157L30.5967 11.3127Z" fill="white"/>
1230 - </svg>
1231 - </div>';
1232 - }
1233 - echo '</div>';
1234 - } else {
1235 - echo '<video id="wpstream-video-vod-'.$now.'" class="'.esc_attr($has_trailer_class).' video-js vjs-default-skin vjs-fluid kuk wpstream_video_on_demand vjs-wpstream ' . $player_theme .' ' . $player_logo_position_class . ' ' . $player_logo_horizontal_position . '" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" data-wpstream-bootstrap="vod" data-instance-id="wpstream-vod-'.esc_attr( $now ).'" data-video-element-id="wpstream-video-vod-'.esc_attr( $now ).'" data-title-overlay-element-id="'.esc_attr( $overlay_video_div_id ).'" data-video-url="'.esc_attr( $video_path_final ).'" data-trailer-url="'.esc_attr( $video_trailer ).'" data-autoplay="'. ( $autoplay ? '1' : '0' ) .'" data-muted="'. ( $muted ? '1' : '0' ) .'" data-captions-url="'.esc_attr( $captionsUrl ).'" data-play-trailer-button-element-id="'.esc_attr( $play_trailer_button_element_id ).'" data-mute-trailer-button-element-id="'.esc_attr( $mute_trailer_button_element_id ).'" data-unmute-trailer-button-element-id="'.esc_attr( $unmute_trailer_button_element_id ).'" data-play-video-button-element-id="'.esc_attr( $play_video_button_element_id ).'" data-player-logo-image="'.esc_attr( $player_logo_image ).'" data-player-logo-position="'.esc_attr( $player_logo_position ).'" data-player-logo-opacity="'.esc_attr( $player_logo_opacity ).'" data-player-logo-width="100" data-player-logo-height="auto" data-player-logo-padding="10" playsinline preload="auto"
1236 - '. $poster_data.' '.$wpstream_data_setup.'>
1237 - <p class="vjs-no-js">
1238 - To view this video please enable JavaScript, and consider upgrading to a web browser that
1239 - <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
1240 - </p>
1241 - </video>';
1242 -
1243 - if($trailer_attachment_id !=0){
1244 - print '<div class="wpstream_theme_trailer_wrapper">';
1245 - print '<div id="'.esc_attr( $play_trailer_button_element_id ).'" class="wpstream_video_on_demand_play_trailer">
1246 - <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1247 - <path fill-rule="evenodd" clip-rule="evenodd" d="M26.6667 1.5H3.33337C2.50495 1.5 1.83337 2.17157 1.83337 3V21C1.83337 21.8284 2.50495 22.5 3.33338 22.5H26.6667C27.4951 22.5 28.1667 21.8284 28.1667 21V3C28.1667 2.17157 27.4951 1.5 26.6667 1.5ZM3.33337 0C1.67652 0 0.333374 1.34315 0.333374 3V21C0.333374 22.6569 1.67652 24 3.33338 24H26.6667C28.3236 24 29.6667 22.6569 29.6667 21V3C29.6667 1.34315 28.3236 0 26.6667 0H3.33337ZM4.83337 4C4.55723 4 4.33337 4.22386 4.33337 4.5V6.16667C4.33337 6.44281 4.55723 6.66667 4.83337 6.66667H6.50004C6.77618 6.66667 7.00004 6.44281 7.00004 6.16667V4.5C7.00004 4.22386 6.77618 4 6.50004 4H4.83337ZM23.5 4C23.2239 4 23 4.22386 23 4.5V6.16667C23 6.44281 23.2239 6.66667 23.5 6.66667H25.1667C25.4428 6.66667 25.6667 6.44281 25.6667 6.16667V4.5C25.6667 4.22386 25.4428 4 25.1667 4H23.5ZM4.33337 11.167C4.33337 10.8909 4.55723 10.667 4.83337 10.667H6.50004C6.77618 10.667 7.00004 10.8909 7.00004 11.167V12.8337C7.00004 13.1098 6.77618 13.3337 6.50004 13.3337H4.83337C4.55723 13.3337 4.33337 13.1098 4.33337 12.8337V11.167ZM23.5001 10.667C23.224 10.667 23.0001 10.8909 23.0001 11.167V12.8337C23.0001 13.1098 23.224 13.3337 23.5001 13.3337H25.1668C25.4429 13.3337 25.6668 13.1098 25.6668 12.8337V11.167C25.6668 10.8909 25.4429 10.667 25.1668 10.667H23.5001ZM4.33337 17.833C4.33337 17.5569 4.55723 17.333 4.83337 17.333H6.50004C6.77618 17.333 7.00004 17.5569 7.00004 17.833V19.4997C7.00004 19.7758 6.77618 19.9997 6.50004 19.9997H4.83337C4.55723 19.9997 4.33337 19.7758 4.33337 19.4997V17.833ZM23.5001 17.333C23.224 17.333 23.0001 17.5569 23.0001 17.833V19.4997C23.0001 19.7758 23.224 19.9997 23.5001 19.9997H25.1668C25.4429 19.9997 25.6668 19.7758 25.6668 19.4997V17.833C25.6668 17.5569 25.4429 17.333 25.1668 17.333H23.5001ZM19.0677 13.0997L13.4077 16.5087C13.0434 16.7281 12.6092 16.7094 12.2661 16.5091C11.9218 16.3081 11.6666 15.9224 11.6666 15.4086V8.59072C11.6666 8.07698 11.9218 7.69125 12.2661 7.49026C12.6092 7.28999 13.0434 7.27126 13.4077 7.49064L19.0677 10.8996C19.8663 11.3805 19.8663 12.6188 19.0677 13.0997Z"/>
1248 - </svg>
1249 - '.esc_html__('Play Trailer','wpstream').'</div>';
1250 -
1251 - print '<div class="wpstream_video_on_demand_play_video_wrapper" id="'.esc_attr( $play_video_button_element_id ).'" >
1252 - <div class="wpstream_video_on_demand_play_video">
1253 - <svg width="29" height="30" viewBox="0 0 29 30" fill="none" xmlns="http://www.w3.org/2000/svg">
1254 - <path fill-rule="evenodd" clip-rule="evenodd" d="M6.1808 28.9035L26.274 18.1652C29.1087 16.6503 29.1087 12.7497 26.274 11.2348L6.1808 0.496557C4.88769 -0.194506 3.34623 -0.1355 2.1283 0.495357C0.906043 1.12846 1.0095e-06 2.34351 9.38766e-07 3.96179L0 25.4382C-7.07369e-08 27.0565 0.906042 28.2715 2.1283 28.9046C3.34622 29.5355 4.88769 29.5945 6.1808 28.9035ZM24.8221 13.8026C25.5742 14.2045 25.5742 15.1955 24.8221 15.5974L4.72891 26.3356C3.94628 26.7539 3.01386 26.2165 3.01386 25.4382L3.01386 3.96179C3.01386 3.18347 3.94628 2.6461 4.72891 3.06436L24.8221 13.8026Z" fill="#F1F1F1"/>
1255 - </svg>
1256 - </div>
1257 - '.esc_html__('Play Video','wpstream').'
1258 - </div>';
1259 -
1260 -
1261 -
1262 - print '<div id="'.esc_attr( $mute_trailer_button_element_id ).'" class="wpstream_video_on_demand_mute_trailer">
1263 -
1264 - <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
1265 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.32143 10.0789H8.69499L18.8964 0L21.1428 0.921053V35.1316L18.8964 36L8.69499 25.8684H1.32143L0 24.5526V11.3947L1.32143 10.0789ZM10.175 23.6842L18.5 31.9474V4.10526L10.175 12.3158L9.24999 12.7105H2.64286V23.2368H9.24999L10.175 23.6842ZM37 17.9737C37.0069 22.2216 35.5329 26.3401 32.8295 29.6263L30.9478 27.7579C33.1613 24.9734 34.3629 21.5249 34.3571 17.9737C34.3571 14.2895 33.0885 10.8974 30.9637 8.21053L32.8454 6.34211C35.5382 9.62494 37.0062 13.735 37 17.9737ZM31.7143 17.9737C31.7193 20.8255 30.7895 23.6011 29.0661 25.8789L27.1738 23.9947C28.4127 22.2295 29.0752 20.1272 29.0714 17.9737C29.0751 15.8287 28.4174 13.7344 27.1871 11.9737L29.0793 10.0895C30.7338 12.2868 31.7143 15.0158 31.7143 17.9737ZM26.4286 17.9737C26.4286 19.4842 26.0057 20.8947 25.2657 22.0947L23.3126 20.1526C23.6249 19.4729 23.7876 18.7345 23.7899 17.9869C23.7922 17.2394 23.634 16.5001 23.3258 15.8184L25.2789 13.8737C26.0083 15.0684 26.4286 16.4737 26.4286 17.9737Z" fill="white"/>
1266 - </svg>
1267 - </div>';
1268 - print '<div id="'.esc_attr( $unmute_trailer_button_element_id ).'" class="wpstream_video_on_demand_unmute_trailer">
1269 - <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
1270 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.15625 8.85688H7.60813L16.5344 0L18.5 0.809375V30.8719L16.5344 31.635L7.60813 22.7319H1.15625L0 21.5756V10.0131L1.15625 8.85688ZM8.90313 20.8125L16.1875 28.0738V3.6075L8.90313 10.8225L8.09375 11.1694H2.3125V20.4194H8.09375L8.90313 20.8125ZM30.5967 11.3127L32.2316 12.9477L28.2287 16.9506L32.2316 20.9559L30.5967 22.5908L26.5938 18.5856L22.5885 22.5908L20.9536 20.9559L24.9588 16.9506L20.9513 12.95L22.5862 11.3151L26.5938 15.3157L30.5967 11.3127Z" fill="white"/>
1271 - </svg>
1272 -
1273 - </div>';
1274 - print '</div>';
1275 - }
1276 - }
1277 - }else{
1278 - print '<div class="wpstream_insuficent_res">'.esc_html__('Insufficient resources to stream this title','wpstream').'</div>';
1279 - }
1280 -
1281 807 }
1282 808
1283 809
1284 810
1285 - /**
1286 - * VODPlayer url - only trailer - used in theme
1287 - *
1288 - * @author cretu
1289 - */
1290 - public function wpstream_video_on_demand_player_only_trailer($product_id){
1291 - wp_enqueue_script('video.min');
1292 - wp_enqueue_script('wpstream-player');
1293 -
1294 - $player_theme = $this->wpstream_get_player_theme();
1295 - $now = time().rand(0,1000000);
1296 - $overlay_video_div_id = "random_id_".$now;
1297 - $this->wpstream_render_vod_title_overlay(
1298 - $overlay_video_div_id,
1299 - get_the_title($product_id)
1300 - );
1301 -
1302 -
1303 -
1304 - $thumb_id = get_post_thumbnail_id($product_id);
1305 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
1306 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
1307 -
1308 - $poster_thumb = '';
1309 - if(isset($thumb[0])){
1310 - $poster_thumb=$thumb[0];
1311 - }
1312 -
1313 -
1314 - $trailer_attachment_id = intval (get_post_meta( $product_id, 'video_trailer', true ));
1315 - $video_trailer = '';
1316 - $video_trailer_type = '';
1317 - if($trailer_attachment_id!=0) {
1318 - $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
1319 - $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
1320 - if(isset($attachment_metadata['mime_type'])){
1321 - $video_trailer_type = $attachment_metadata['mime_type'];
1322 - }
1323 -
1324 - }
1325 -
1326 -
1327 - $autoplay = false;
1328 - $muted = false;
1329 -
1330 - if( intval ( get_option('wpstream_vod_start_muted','') ) === 1){
1331 - $muted = true;
1332 - }
1333 - if( intval ( get_option('wpstream_vod_autoplay','') ) === 1 ){
1334 - $autoplay = true;
1335 - }
1336 - $video_path_final='';
1337 - $has_trailer_class='wpstream_theme_player_has_trailer';
1338 - $captions_url = get_post_meta( $product_id, 'wpstream_closed_captions_file', true );
1339 - $play_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_play_trailer_btn_' . $now : '';
1340 - $mute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_mute_trailer_btn_' . $now : '';
1341 - $unmute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_unmute_trailer_btn_' . $now : '';
1342 -
1343 - echo '<video id="wpstream-video-vod-'.$now.'" class="video-js vjs-default-skin vjs-fluid kuk wpstream_video_on_demand vjs-wpstream '.esc_attr( $has_trailer_class ).' ' . $player_theme . '" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" data-wpstream-bootstrap="vod" data-instance-id="wpstream-vod-trailer-'.esc_attr( $now ).'" data-video-element-id="wpstream-video-vod-'.esc_attr( $now ).'" data-title-overlay-element-id="'.esc_attr( $overlay_video_div_id ).'" data-video-url="" data-trailer-url="'.esc_attr( $video_trailer ).'" data-autoplay="'. ( $autoplay ? '1' : '0' ) .'" data-muted="'. ( $muted ? '1' : '0' ) .'" data-captions-url="'.esc_attr( $captions_url ).'" data-play-trailer-button-element-id="'.esc_attr( $play_trailer_button_element_id ).'" data-mute-trailer-button-element-id="'.esc_attr( $mute_trailer_button_element_id ).'" data-unmute-trailer-button-element-id="'.esc_attr( $unmute_trailer_button_element_id ).'" playsinline preload="auto"
1344 - >
1345 - <p class="vjs-no-js">
1346 - To view this video please enable JavaScript, and consider upgrading to a web browser that
1347 - <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
1348 - </p>
1349 - </video>';
1350 -
1351 - if($trailer_attachment_id !=0){
1352 - print '<div class="wpstream_theme_trailer_wrapper">';
1353 - print '<div id="'.esc_attr( $play_trailer_button_element_id ).'" class="wpstream_video_on_demand_play_trailer">
1354 - <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1355 - <path fill-rule="evenodd" clip-rule="evenodd" d="M26.6667 1.5H3.33337C2.50495 1.5 1.83337 2.17157 1.83337 3V21C1.83337 21.8284 2.50495 22.5 3.33338 22.5H26.6667C27.4951 22.5 28.1667 21.8284 28.1667 21V3C28.1667 2.17157 27.4951 1.5 26.6667 1.5ZM3.33337 0C1.67652 0 0.333374 1.34315 0.333374 3V21C0.333374 22.6569 1.67652 24 3.33338 24H26.6667C28.3236 24 29.6667 22.6569 29.6667 21V3C29.6667 1.34315 28.3236 0 26.6667 0H3.33337ZM4.83337 4C4.55723 4 4.33337 4.22386 4.33337 4.5V6.16667C4.33337 6.44281 4.55723 6.66667 4.83337 6.66667H6.50004C6.77618 6.66667 7.00004 6.44281 7.00004 6.16667V4.5C7.00004 4.22386 6.77618 4 6.50004 4H4.83337ZM23.5 4C23.2239 4 23 4.22386 23 4.5V6.16667C23 6.44281 23.2239 6.66667 23.5 6.66667H25.1667C25.4428 6.66667 25.6667 6.44281 25.6667 6.16667V4.5C25.6667 4.22386 25.4428 4 25.1667 4H23.5ZM4.33337 11.167C4.33337 10.8909 4.55723 10.667 4.83337 10.667H6.50004C6.77618 10.667 7.00004 10.8909 7.00004 11.167V12.8337C7.00004 13.1098 6.77618 13.3337 6.50004 13.3337H4.83337C4.55723 13.3337 4.33337 13.1098 4.33337 12.8337V11.167ZM23.5001 10.667C23.224 10.667 23.0001 10.8909 23.0001 11.167V12.8337C23.0001 13.1098 23.224 13.3337 23.5001 13.3337H25.1668C25.4429 13.3337 25.6668 13.1098 25.6668 12.8337V11.167C25.6668 10.8909 25.4429 10.667 25.1668 10.667H23.5001ZM4.33337 17.833C4.33337 17.5569 4.55723 17.333 4.83337 17.333H6.50004C6.77618 17.333 7.00004 17.5569 7.00004 17.833V19.4997C7.00004 19.7758 6.77618 19.9997 6.50004 19.9997H4.83337C4.55723 19.9997 4.33337 19.7758 4.33337 19.4997V17.833ZM23.5001 17.333C23.224 17.333 23.0001 17.5569 23.0001 17.833V19.4997C23.0001 19.7758 23.224 19.9997 23.5001 19.9997H25.1668C25.4429 19.9997 25.6668 19.7758 25.6668 19.4997V17.833C25.6668 17.5569 25.4429 17.333 25.1668 17.333H23.5001ZM19.0677 13.0997L13.4077 16.5087C13.0434 16.7281 12.6092 16.7094 12.2661 16.5091C11.9218 16.3081 11.6666 15.9224 11.6666 15.4086V8.59072C11.6666 8.07698 11.9218 7.69125 12.2661 7.49026C12.6092 7.28999 13.0434 7.27126 13.4077 7.49064L19.0677 10.8996C19.8663 11.3805 19.8663 12.6188 19.0677 13.0997Z"/>
1356 - </svg>
1357 - '.esc_html__('Play Trailer','wpstream').'
1358 - </div>';
1359 - print '<div id="'.esc_attr( $mute_trailer_button_element_id ).'" class="wpstream_video_on_demand_mute_trailer">
1360 - <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
1361 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.32143 10.0789H8.69499L18.8964 0L21.1428 0.921053V35.1316L18.8964 36L8.69499 25.8684H1.32143L0 24.5526V11.3947L1.32143 10.0789ZM10.175 23.6842L18.5 31.9474V4.10526L10.175 12.3158L9.24999 12.7105H2.64286V23.2368H9.24999L10.175 23.6842ZM37 17.9737C37.0069 22.2216 35.5329 26.3401 32.8295 29.6263L30.9478 27.7579C33.1613 24.9734 34.3629 21.5249 34.3571 17.9737C34.3571 14.2895 33.0885 10.8974 30.9637 8.21053L32.8454 6.34211C35.5382 9.62494 37.0062 13.735 37 17.9737ZM31.7143 17.9737C31.7193 20.8255 30.7895 23.6011 29.0661 25.8789L27.1738 23.9947C28.4127 22.2295 29.0752 20.1272 29.0714 17.9737C29.0751 15.8287 28.4174 13.7344 27.1871 11.9737L29.0793 10.0895C30.7338 12.2868 31.7143 15.0158 31.7143 17.9737ZM26.4286 17.9737C26.4286 19.4842 26.0057 20.8947 25.2657 22.0947L23.3126 20.1526C23.6249 19.4729 23.7876 18.7345 23.7899 17.9869C23.7922 17.2394 23.634 16.5001 23.3258 15.8184L25.2789 13.8737C26.0083 15.0684 26.4286 16.4737 26.4286 17.9737Z" fill="white"/>
1362 - </svg>
1363 -
1364 -
1365 - </div>';
1366 - print '<div id="'.esc_attr( $unmute_trailer_button_element_id ).'" class="wpstream_video_on_demand_unmute_trailer">
1367 - <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
1368 - <path fill-rule="evenodd" clip-rule="evenodd" d="M1.15625 8.85688H7.60813L16.5344 0L18.5 0.809375V30.8719L16.5344 31.635L7.60813 22.7319H1.15625L0 21.5756V10.0131L1.15625 8.85688ZM8.90313 20.8125L16.1875 28.0738V3.6075L8.90313 10.8225L8.09375 11.1694H2.3125V20.4194H8.09375L8.90313 20.8125ZM30.5967 11.3127L32.2316 12.9477L28.2287 16.9506L32.2316 20.9559L30.5967 22.5908L26.5938 18.5856L22.5885 22.5908L20.9536 20.9559L24.9588 16.9506L20.9513 12.95L22.5862 11.3151L26.5938 15.3157L30.5967 11.3127Z" fill="white"/>
1369 - </svg>
1370 -
1371 - </div>';
1372 - print '</div>';
1373 - }
1374 - else {
1375 - //just show the poster or don't show anything; no player needed
1376 - }
1377 -
1378 - }
1379 -
1380 811
1381 812
813 +
1382 814 /**
1383 - *
1384 - * edited 4.0
1385 - *
1386 815 * Retreive username for vod path
1387 816 *
1388 817 * @author cretu
1389 818 */
1390 819 private function wpstream_retrive_username(){
1391 -
1392 - return get_option('wpstream_api_username_from_token');
1393 - }
820 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
1394 821
1395 - /**
1396 - * Render title overlay via action hook.
1397 - *
1398 - * @param string $overlay_id Overlay element id.
1399 - * @param string $title_text Title text.
1400 - */
1401 - private function wpstream_render_vod_title_overlay( $overlay_id, $title_text ) {
1402 - if ( has_action( 'wpstream_vod_title_overlay' ) ) {
1403 - do_action(
1404 - 'wpstream_vod_title_overlay',
1405 - $overlay_id,
1406 - $title_text,
1407 - esc_html__( 'Playing:', 'wpstream' )
1408 - );
822 + $url=WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/return_login/?access_token=".$token;
823 + $arguments = array(
824 + 'method' => 'GET',
825 + 'timeout' => 45,
826 + 'redirection' => 5,
827 + 'httpversion' => '1.0',
828 + 'blocking' => true,
829 + 'headers' => array(),
830 + 'cookies' => array()
831 + );
832 + $response = wp_remote_post($url,$arguments);
833 + $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
834 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
835 + return ($received_data); die();
836 + }else{
837 + print 'Failed to conbect media server';
838 + die();
1409 839 }
1410 - }
840 + }
1411 841
1412 - /**
1413 - * check if the we can add display the player
1414 - *
1415 - * @since 3.12
1416 - * returns html of the player
1417 - */
1418 842
1419 - public function wpstream_check_if_player_can_dsplay($product_id){
1420 - if ( is_user_logged_in() ) {
1421 -
1422 - $term_list = wp_get_post_terms($product_id, 'product_type');
1423 - $current_user = wp_get_current_user();
1424 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1425 -
1426 - $product = wc_get_product($product_id);
1427 - $product_type = $product->get_type();
1428 -
1429 843
1430 - if($subscription_model==1){ // if we have Neflix mode
1431 - if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
1432 - return false;
1433 - }
1434 - if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
1435 - return true;
1436 - }
1437 - }else{
1438 - // ppv mode
1439 -
1440 - if( $product_type=='subscription' ){
1441 -
1442 -// $user_subscriptions = wcs_get_users_subscriptions($current_user->ID );
1443 -// foreach ($user_subscriptions as $subscription) {
1444 -// $subscription_status = $subscription->get_status();
1445 -// echo "</br>*** Subscription ID $subscription->ID for User ID $current_user->ID has status: $subscription_status";
1446 -// }
1447 -
1448 844
1449 - if( wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
1450 - // user has active subcription
1451 - return true;
1452 - }
1453 -
1454 - }else{
1455 - if( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id)){
1456 - return true;
1457 - }
1458 - }
1459 -
1460 -
1461 - }
1462 - return false;
1463 -
1464 - }
1465 - return false;
1466 845
1467 - }
1468 -
1469 -
846 + /**
847 + * check if the user bought the product and display the player - TO REDo
848 + *
849 + * @since 3.0.1
850 + * returns html of the player
851 + */
852 + public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
1470 853
1471 - /**
1472 - * check if the we can add display the player - theme variant
1473 - *
1474 - * @since 3.12
1475 - * returns html of the player
1476 - */
1477 - public function wpstream_check_if_player_can_dsplay_theme($product_id){
1478 -
1479 - $post_type= get_post_type($product_id);
1480 -
854 + if ( is_user_logged_in() ) {
855 + global $product;
856 + $current_user = wp_get_current_user();
857 + $product_id = $product->get_id();
1481 858
1482 -
1483 - if($post_type=='wpstream_product_vod' || $post_type=='wpstream_product'){
1484 - return true; // if we have free vod or live
1485 - }
1486 859
860 + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) || ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){
1487 861
1488 862
1489 - if ( is_user_logged_in() && $post_type==='product' ) {
1490 -
1491 - $product = wc_get_product( $product_id );
1492 - $product_type = $product->get_type();
1493 - $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle',true);
1494 -
863 + echo '<div class="wpstream_player_wrapper"><div class="wpstream_player_container">';
1495 864
1496 -
1497 -
1498 -
1499 - $current_user = wp_get_current_user();
1500 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1501 - // print 'subscription model '.$subscription_model.'</br>';
1502 -
1503 - if($subscription_model==1){ // if we have Neflix mode
1504 - if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
1505 - return false;
1506 - }
1507 - if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
1508 - return true;
1509 - }
1510 - }else{
1511 - // ppv mode
1512 - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ){
1513 - return true; //simple product bought
1514 - }else if (function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ){
1515 - return true; // subscription boght
1516 - }else if( get_post_type($product_id) =='product' &&
1517 - intval($possible_bundle )!=0 &&
1518 - wc_customer_bought_product( $current_user->user_email, $current_user->ID, $possible_bundle)
1519 - ){
1520 - return true; // part of a boght bundle
1521 - }
1522 - }
1523 - // print ' fac return false </br>';
1524 - return false;
1525 -
1526 - }
1527 - return false;
1528 -
1529 - }
1530 -
1531 -
1532 - /**
1533 - * in plugin - check if global subscription model is enabled
1534 - *
1535 - * @since 3.12
1536 - *
1537 - */
1538 - public function wpstream_in_plugin_check_global_subscription_model($product_id) {
1539 -
1540 - // $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
1541 - if( is_user_logged_in() && function_exists('wcs_user_has_subscription') ){
1542 -
1543 - global $woocommerce;
1544 - $current_user = wp_get_current_user();
1545 -
1546 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1547 - $main_subscription = intval( get_option('wpstream_global_sub_id',''));
1548 -
1549 - if($subscription_model==1){
1550 - $selected_sub= get_post_meta($product_id,'_wpstream_parent_sub',true) ;
1551 -
1552 - if( is_array($selected_sub) ){
1553 -
1554 - // we have per product sub
1555 - foreach($selected_sub as $key=>$subscrition_id ):
1556 - if( wcs_user_has_subscription( $current_user->ID, $subscrition_id ,'active') ) {
1557 - return true;
1558 - }
1559 - endforeach;
1560 -
1561 - } else if($main_subscription!=0){
1562 -
1563 - // if we have one main subscription
1564 - if( wcs_user_has_subscription( $current_user->ID, $main_subscription ,'active') ) {
1565 - return true;
1566 - }
1567 - }
1568 -
1569 -
1570 - }
1571 - return false;
1572 -
1573 - }
1574 - // there is no woo subscription or user not logged in
1575 - return false;
1576 - }
1577 -
1578 -
1579 -
1580 -
1581 -
1582 -
1583 -
1584 -
1585 -
1586 - /**
1587 - *
1588 - *
1589 - *
1590 - *
1591 - * check if the user bought the product and display the player - TO REDo
1592 - *
1593 - * @since 3.0.1
1594 - * returns html of the player
1595 - *
1596 - *
1597 - *
1598 - *
1599 - *
1600 - */
1601 - public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
1602 - if(function_exists('wpstream_remove_wpstream_filter')){
1603 - return;
1604 - }
1605 - global $product;
1606 - $product_id = $product->get_id();
1607 - $current_user = wp_get_current_user();
1608 -
1609 - if ( is_user_logged_in() ) {
1610 -
1611 -
1612 - if($this->wpstream_check_if_player_can_dsplay($product_id) ){
1613 -
1614 - echo '<div class="wpstream_player_wrapper "><div class="wpstream_player_container">';
1615 -
1616 865 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
1617 866 $term_list = wp_get_post_terms($product_id, 'product_type');
1618 867
1619 868
@@ -1619,50 +868,29 @@
1619 868
1620 869 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
1621 870 $this->wpstream_live_event_player($product_id);
1622 871 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
1623 -
1624 872 $this->wpstream_video_on_demand_player($product_id);
1625 873 }
1626 874 echo '</div></div>';
1627 875 }else{
1628 -
1629 -
1630 - $term_list = wp_get_post_terms($product_id, 'product_type');
1631 -
1632 - if( $term_list[0]->name=='subscription' ){
1633 -
1634 - if( !wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
1635 - $this->wpstream_display_no_buy_message('nobuy',$product_id);
1636 - }
1637 -
1638 - }else{
1639 - $this->wpstream_display_no_buy_message('nobuy',$product_id);
876 + if( get_post_type($product_id) == 'wpstream_product' ){
877 + echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
878 + echo '<div class="wpstream_notice">'.__('You did not buy this product!','wpstream').'</div>';
879 + echo '</div></div>';
1640 880 }
1641 -
1642 -
1643 -
1644 881 }
1645 882
1646 883
1647 - }else{
1648 -
1649 - $this->wpstream_display_no_buy_message('nolog',$product_id);
1650 884 }
1651 885 }
1652 886
1653 -
1654 -
1655 -
1656 -
1657 - /**
1658 - *
1659 - *
1660 - * check if the user bought the product and display the player - TO REDo
1661 - *
1662 - * @since 3.0.1
887 + /**
888 + * check if the user bought the product and display the player - TO REDo
889 + *
890 + * @since 3.0.1
1663 891 * returns html of the player
1664 - */
892 + */
1665 893
1666 894 public function wpstream_chat_wrapper($product_id){
1667 895 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/templates/wpstream_chat_template.php';
1668 896 }
@@ -1668,23 +896,9 @@
1668 896 }
1669 897
1670 898
1671 899
1672 -
1673 -
1674 -
1675 -
1676 -
1677 - /**
1678 - * coonect to chat
1679 - *
1680 - * @since 1.12.2
1681 - *
1682 - */
1683 -
1684 -
1685 -
1686 - public function wpstream_connect_to_chat($product_id){
900 + public function wpstream_connect_to_chat($product_id){
1687 901 $current_user = wp_get_current_user();
1688 902 $userID = $current_user->ID;
1689 903 $user_login = $current_user->user_login;
1690 904
@@ -1689,9 +903,9 @@
1689 903 $user_login = $current_user->user_login;
1690 904
1691 905 $key='';
1692 906
1693 - $chat_url = get_post_meta($product_id,'chat_url',true);
907 + $chatUrl = get_post_meta($product_id,'chatUrl',true);
1694 908
1695 909
1696 910 wp_enqueue_script( 'sockjs-0.3.min' );
1697 911 wp_enqueue_script( 'emojione.min.js' );
@@ -1711,9 +925,9 @@
1711 925
1712 926
1713 927 if(!is_user_logged_in()){
1714 928 $user_login='';
1715 - $chat_url='';
929 + $chatUrl='';
1716 930 }
1717 931
1718 932
1719 933 print '<script type="text/javascript">
@@ -1726,117 +940,5 @@
1726 940 //]]>
1727 941 </script>';
1728 942
1729 943 }
1730 -
1731 -
1732 - /**
1733 - * display no buy Message
1734 - *
1735 - * @since 3.12.2
1736 - *
1737 - */
1738 - public function wpstream_display_no_buy_message($log,$product_id) {
1739 -
1740 - if($log=='sub_active'){
1741 - $message= esc_html( get_option('wpstream_subscription_active','Your Subscription is Active.')) ;
1742 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1743 - echo '<div class="wpstream_notice"> '.$message.'</div>';
1744 - echo '</div></div>';
1745 - return;
1746 -
1747 - }else if($log=='nolog'){
1748 - $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
1749 - }else{
1750 - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
1751 - }
1752 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1753 - if($subscription_model==1){
1754 - $message =esc_html( get_option('wpstream_product_not_subscribe','You did not yet subscribe to this item.'));
1755 - }
1756 -
1757 -
1758 - if( get_post_type($product_id) == 'product' && $subscription_model==0 ){
1759 - $product = wc_get_product($product_id);
1760 - $term_list = wp_get_post_terms($product_id, 'product_type');
1761 - $product_type = $product->get_type();
1762 - $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
1763 -
1764 -
1765 -
1766 - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream' || $product_type=='subscription'){
1767 -
1768 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1769 - echo '<div class="wpstream_notice">'.$message.'</div>';
1770 - echo '</div></div>';
1771 -
1772 - }
1773 -
1774 - }else if( get_post_type($product_id) == 'product' && $subscription_model==1 ){
1775 - $term_list = wp_get_post_terms($product_id, 'product_type');
1776 - if( $term_list[0]->name!=='simple'){
1777 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1778 - echo '<div class="wpstream_notice"> '.$message.'</div>';
1779 - echo '</div></div>';
1780 - }
1781 - }
1782 -
1783 -
1784 -
1785 -
1786 -
1787 -
1788 - }
1789 -
1790 - /**
1791 - * Get the video player logo URL.
1792 - *
1793 - * @param int $product_id Product ID.
1794 - * @return mixed|string
1795 - */
1796 - public function wpstream_get_video_player_logo( $product_id ) {
1797 - $is_streamify_user = $this->wpstream_is_streamify_user( $product_id );
1798 - if ( $is_streamify_user ) {
1799 - return WPSTREAM_PLUGIN_DIR_URL . 'img/wpstream-symbol-large.png';
1800 - }
1801 -
1802 - $logo = get_option( 'wpstream_player_logo', '' );
1803 - if ( ! empty( $logo ) ) {
1804 - return $logo;
1805 - }
1806 -
1807 - return '';
1808 - }
1809 -
1810 - /**
1811 - * Get cached pack data or request fresh pack data
1812 - *
1813 - * @param bool $force_refresh Force a refresh of the cached data
1814 - * @return array Pack data
1815 - */
1816 - private function wpstream_get_cached_pack_data( $force_refresh = false ) {
1817 - $cached_data = get_transient( 'wpstream_user_pack_data' );
1818 -
1819 - if ( $force_refresh || $cached_data === false ) {
1820 - $fresh_data = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_get_cached_pack_data');
1821 - set_transient( 'wpstream_user_pack_data', $fresh_data, 60);
1822 -
1823 - return $fresh_data;
1824 - }
1825 -
1826 - return $cached_data;
1827 - }
1828 -
1829 - /*
1830 - * Check if the user is on a basic subscription
1831 - *
1832 - * @param int $channel_id Channel ID
1833 - * @return bool
1834 - */
1835 - public function wpstream_is_streamify_user( $channel_id ) {
1836 - $is_basic_streaming = get_post_meta( $channel_id, 'basicStreaming', true );
1837 - if ( $is_basic_streaming === '1' ) {
1838 - return true;
1839 - }
1840 - return false;
1841 - }
1842 944 }