PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.4.10
WpStream – Live Streaming, Video on Demand, Pay Per View v4.4.10
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 +288 -1260 4.12.44.4.10 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,9 +20,13 @@
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 +
27 +
28 +
35 29 }
36 30
37 31
38 32
@@ -48,34 +42,29 @@
48 42 * @author cretu
49 43 */
50 44
51 45 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']);
46 + $channel_id = intval($_POST['channel_id']);
55 47
56 48
57 - $transient_name = 'event_data_to_return_'. $channel_id;
58 - $event_data_for_transient = get_transient( $transient_name );
49 + $transient_name = 'event_data_to_return_'. $channel_id;
50 + $event_data_for_transient = get_transient( $transient_name );
59 51
60 52
61 - $usefull_info =' get cache from transiet';
53 +
62 54 if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
63 55 $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);
56 + $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
65 57 $event_data_for_transient = $event_status;
66 - $usefull_info =' no cache found';
58 +
67 59 set_transient($transient_name,$event_data_for_transient,45);
68 60 }
69 61
70 62
71 63 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();
74 64 echo json_encode( array(
75 65
76 66 'started' => 'yes',
77 - 'usefull_info' => $usefull_info,
78 67 'channel_id' => $channel_id,
79 68 'event_uri' => $event_data_for_transient['hls_playback_url'],
80 69 'live_conect_views' => $event_data_for_transient['stats_url'],
81 70 'chat_url' => $event_data_for_transient['chat_url'],
@@ -82,25 +71,20 @@
82 71 '$event_data_for_transient'=>$event_data_for_transient
83 72
84 73
85 74 ));
86 - $usedfull_info =' ';
87 75 update_post_meta($channel_id,'stream_name',$event_data_for_transient['stream_name']);
88 76 update_post_meta($channel_id,'hls_key_retrieval_url',$event_data_for_transient['hls_key_retrieval_url']);
89 77 delete_transient( 'free_event_streamName_'.$event_data_for_transient['stream_name']);
90 78
91 79 }else{
92 - // cleanup any previous echo before sending json
93 - ob_end_clean();
94 80 echo json_encode( array(
95 81 'started' => 'no',
96 - 'usefull_info' => $usefull_info,
97 82 'server_id' => '',
98 - 'channel_id' => $channel_id,
83 + 'channel_id' => $channel_id,
99 84 'event_uri' => '',
100 85 'live_conect_views' => '',
101 86 'chat_url' => '',
102 -
103 87
104 88 ));
105 89
106 90 }
@@ -115,12 +99,8 @@
115 99 *
116 100 * @author cretu
117 101 */
118 102 public function wpstream_filter_the_title( $content ) {
119 - if(function_exists('wpstream_remove_wpstream_filter')){
120 - return $content;
121 - }
122 -
123 103 if( is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){
124 104 global $post;
125 105 $args=array('id'=>$post->ID);
126 106 $custom_content = $this->wpstream_insert_player_inpage($args);
@@ -172,32 +152,23 @@
172 152 * @author cretu
173 153 */
174 154
175 155 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 156
181 - wp_enqueue_script('video.min');
182 - wp_enqueue_script('wpstream-player');
157 +
183 158
184 159 if ( is_user_logged_in() ) {
185 160 global $product;
186 161 $current_user = wp_get_current_user();
187 162 $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);
163 + $term_list = wp_get_post_terms($product_id, 'product_type');
164 +
190 165
191 166
192 167
193 168
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' ){
169 + 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) )
170 + || get_post_type($product_id)=='wpstream_product' || get_post_type($product_id)=='wpstream_product_vod' ){
200 171 global $product;
201 172 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
202 173
203 174
@@ -221,10 +192,9 @@
221 192 }else{
222 193
223 194 if( get_post_type($product_id) == 'product' ){
224 195 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>';
196 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
227 197 echo '</div></div>';
228 198 }
229 199 }
230 200
@@ -231,26 +201,12 @@
231 201
232 202 }else{
233 203
234 204 $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.')) ;
241 -
242 -
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>';
205 + if( get_post_type($product_id) == 'wpstream_product' ){
206 + $this->wpstream_live_event_player($product_id);
249 207 } 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>';
208 + $this->wpstream_video_on_demand_player($product_id);
253 209 }
254 210 }
255 211 }
256 212
@@ -262,16 +218,9 @@
262 218 * @author cretu
263 219 */
264 220
265 221 public function wpstream_video_player_shortcode_low_latency($from_sh_id='') {
266 - if ( !defined( 'DONOTCACHEPAGE' ) ) {
267 - define( 'DONOTCACHEPAGE', true );
268 - }
269 222
270 - wp_enqueue_script('video.min');
271 - wp_enqueue_script('wpstream-player');
272 -
273 -
274 223 if ( is_user_logged_in() ) {
275 224 global $product;
276 225 $current_user = wp_get_current_user();
277 226 $product_id = intval($from_sh_id);
@@ -298,11 +247,9 @@
298 247 }else{
299 248
300 249 if( get_post_type($product_id) == 'product' ){
301 250 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>';
251 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
305 252 echo '</div></div>';
306 253 }
307 254 }
308 255
@@ -332,114 +279,8 @@
332 279 }
333 280 }
334 281 return $url;
335 282 }
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 283
443 284 /**
444 285 * Get event settings
445 286 *
@@ -447,45 +288,15 @@
447 288 */
448 289
449 290 function wpestream_return_event_settings($product_id){
450 291
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 = isset( $local_event_options ) &&
454 - ( ! isset( $use_global_event_options ) || (int) $use_global_event_options === 0 );
455 -
456 - if( !$is_local_event_options_enabled ) {
292 + $local_event_options = get_post_meta($product_id,'local_event_options',true);
293 + if(!is_array($local_event_options)){
457 294 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
458 295 }
459 296
460 297 return $local_event_options;
461 298 }
462 -
463 - /**
464 - * Localized strings for live player UI (parent overlay + iframe postMessage).
465 - *
466 - * @return array<string,string|bool>
467 - */
468 - private function wpstream_get_player_i18n_config() {
469 - return array(
470 - 'wpstream_player_state_stopped_msg' => esc_html(
471 - get_option(
472 - 'wpstream_you_are_not_live',
473 - __( 'We are not live at this moment', 'wpstream' )
474 - )
475 - ),
476 - 'wpstream_player_state_init_msg' => esc_html__( 'The live stream has not yet started', 'wpstream' ),
477 - 'wpstream_player_state_startup_msg' => esc_html__( 'The live stream is starting...', 'wpstream' ),
478 - 'wpstream_player_state_paused_msg' => esc_html__( 'The live stream is paused', 'wpstream' ),
479 - 'wpstream_player_state_ended_msg' => esc_html__( 'The live stream has ended', 'wpstream' ),
480 - 'wpstream_player_state_error_msg' => esc_html__( 'Something went wrong', 'wpstream' ),
481 - 'wpstream_player_offair_default_msg' => esc_html__( 'Live stream is not on air.', 'wpstream' ),
482 - 'wpstream_player_max_viewers_msg' => esc_html__( 'Max viewers reached. Please wait', 'wpstream' ),
483 - 'wpstream_player_max_viewers_wait_msg' => esc_html__( 'Max viewers reached. Please wait for %d to leave', 'wpstream' ),
484 - 'wpstream_player_invalid_session_msg' => esc_html__( 'Invalid session. Please refresh and start playback again.', 'wpstream' ),
485 - 'isThemeActive' => get_template() === 'hello-wpstream',
486 - );
487 - }
488 299
489 300
490 301
491 302 /**
@@ -496,368 +307,124 @@
496 307 * @author cretu
497 308 */
498 309
499 310 function wpstream_live_event_player($channel_id,$poster_show='',$use_chat=''){
500 - wp_enqueue_script('video.min');
501 - wp_enqueue_script('wpstream-player');
502 - wp_enqueue_script( 'wpstream-player-controls' );
503 -
504 - wp_localize_script(
505 - 'wpstream-player-controls',
506 - 'wpstreamLiveUiConfig',
507 - $this->wpstream_get_player_i18n_config()
508 - );
509 -
510 - $player_theme = $this->wpstream_get_player_theme( $channel_id );
511 - $now = time().rand(0,1000000);
512 - $overlay_video_div_id = "random_id_".$now;
513 - // 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>';
514 -
515 -
516 - $thumb_id = get_post_thumbnail_id($channel_id);
517 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
518 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
519 - $autoplay = true;
520 -
521 - $event_settings = $this->wpestream_return_event_settings($channel_id);
522 -
523 - $transient_name = 'event_data_to_return_'. $channel_id;
524 - $event_status = get_transient( $transient_name );
525 -
526 - if ( false === $event_status || $event_status=='' ) {
311 +
312 + $now = time().rand(0,1000000);
313 + $thumb_id = get_post_thumbnail_id($channel_id);
314 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
315 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
316 + $autoplay = 'autoplay';
317 +
318 + $event_settings = $this->wpestream_return_event_settings($channel_id);
527 319 $notes = 'wpstream_live_event_player_note';
528 320 $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
529 - set_transient($transient_name, $event_status, 45);
530 - }
321 + $hls_playback_url = '';
322 + $live_conect_views = '';
323 +
324 + if(isset($event_status['status']) && $event_status['status']=='active'){
325 + //live event
326 + if(isset($event_status['hls_playback_url'])){
327 + $hls_playback_url = $event_status['hls_playback_url'];
328 +
329 + update_post_meta($channel_id,'stream_name',$event_status['stream_name']);
330 + update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']);
331 + delete_transient( 'free_event_streamName_'.$event_status['stream_name']);
531 332
532 - $hls_playback_url = '';
533 - $live_conect_views = '';
534 -
535 - if(isset($event_status['status']) && $event_status['status']=='active'){
536 - //live event
537 - if(isset($event_status['hls_playback_url'])){
538 - $hls_playback_url = $event_status['hls_playback_url'];
539 -
540 - update_post_meta($channel_id,'stream_name',$event_status['stream_name']);
541 - update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']);
542 - delete_transient( 'free_event_streamName_'.$event_status['stream_name']);
543 -
333 + $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
334 + $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
335 + $live_conect_views = $this->remove_http($live_conect_views);
336 +
337 + }
338 + if(isset($event_status['chat_url'])){
339 + $chat_url = $event_status['chat_url'];
340 + }
341 +
342 + }else{
343 + // event not live
544 344 }
545 - $live_conect_views = $this->wpstream_get_live_connect_uri($event_status, 'hls_playback_url');
546 - if(isset($event_status['chat_url'])){
547 - $chat_url = $event_status['chat_url'];
345 +
346 +
347 +
348 +
349 +
350 +
351 +
352 + if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
353 + $autoplay='no_autoplay';
548 354 }
355 +
356 + 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.'" > ';
357 +
358 + if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){
359 + echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
360 + }
361 +
362 + $show_wpstream_not_live_mess=' style="display:none;" ';
363 + if(trim($hls_playback_url) ==''){
364 +
365 + $show_wpstream_not_live_mess='';
366 + }
367 +
368 + $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment. Please check back later.')) ;
369 + 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($message_show).'</div></div>';
549 370
550 - }else{
551 - // event not live
552 - }
371 + $poster_data='';
372 + if(isset($thumb[0])){
373 + $poster_data=' poster="'.$thumb[0].'" ';
374 + }
375 + if($poster_show=='no'){
376 + $poster_data='';
377 + }
553 378
554 - $trailer_attachment_id = intval( get_post_meta( $channel_id, 'video_trailer', true ) );
555 - $video_trailer = '';
556 - $has_trailer_class = '';
557 - if ( $trailer_attachment_id != 0 ) {
558 - $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
559 - $attachment_metadata = wp_get_attachment_metadata( $trailer_attachment_id );
560 - if ( isset ( $attachment_metadata['mime_type'] ) ) {
561 - $video_trailer_type = $attachment_metadata['mime_type'];
562 - }
563 - $poster_data = ''; // cancel poster for theme
564 - $has_trailer_class = 'wpstream_theme_player_has_trailer';
565 - }
566 -
567 - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
568 - $autoplay=false;
569 - }
379 + $is_muted='';
380 + if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
381 + $is_muted=' muted ';
382 + }
383 +
384 +
385 +
386 + echo'
387 + <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.'>
388 + <source
389 + src="'.$hls_playback_url.'"
390 + type="application/x-mpegURL">
391 + </video>';
570 392
571 - $bootstrap_is_muted = ( isset( $event_settings['mute'] ) && intval( $event_settings['mute'] ) === 1 );
572 - $bootstrap_trailer_attachment_id = intval( get_post_meta( $channel_id, 'video_trailer', true ) );
573 - $bootstrap_trailer_url = '';
574 - if ( $bootstrap_trailer_attachment_id !== 0 ) {
575 - $bootstrap_trailer_url = wp_get_attachment_url( $bootstrap_trailer_attachment_id );
393 + print '<script type="text/javascript">
394 + //<![CDATA[
395 + jQuery(document).ready(function(){
396 + wpstream_player_initialize("'.$now.'","'.$hls_playback_url.'","'.$live_conect_views.'","'.$autoplay.'");';
397 + print'});
398 + //]]>
399 + </script>';
400 + print '</div>';
401 +
402 +
403 + if(trim($hls_playback_url) ==''){
404 + // $show_wpstream_not_live_mess='';
405 + }else{
406 + print '<script type="text/javascript">
407 + //<![CDATA[
408 + jQuery(document).ready(function(){
409 + var player_wrapper = jQuery(".wpstream_live_player_wrapper");
410 + wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'");
411 + });
412 + //]]>
413 + </script>';
414 + }
415 +
416 +
417 + if($use_chat=="yes"){
418 + $this->wpstream_connect_to_chat($channel_id);
419 + }
420 +
421 + usleep (10000);
422 +
576 423 }
577 - $live_content_uri = isset( $hls_playback_url ) ? trim( $hls_playback_url ) : '';
578 - $live_stats_uri = isset( $live_conect_views ) ? trim( $live_conect_views ) : '';
579 - $live_chat_uri = isset( $chat_url ) ? trim( $chat_url ) : '';
580 - $play_trailer_button_element_id = 'wpstream_live_video_play_trailer_btn_' . $now;
581 - $mute_trailer_button_element_id = 'wpstream_live_video_mute_trailer_btn_' . $now;
582 - $unmute_trailer_button_element_id = 'wpstream_live_video_unmute_trailer_btn_' . $now;
583 424
584 425
585 426
586 - $player_nonce = wp_create_nonce( 'wpstream_player_check_status_nonce' );
587 -
588 - $live_channel_embed_url = get_post_meta( $channel_id, 'embedUrl', true );
589 -
590 - // if embedUrl is set, we are using the new player
591 - if ( !$live_channel_embed_url ) {
592 - 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 ) . '" > ';
593 -
594 - $show_viewer_count = (
595 - ( isset( $event_settings['view_count'] ) && intval( $event_settings['view_count'] ) == 1 )
596 - || ! isset( $event_settings['view_count'] )
597 - );
598 -
599 - echo '<div id="wpestream_live_counting" class="wpestream_live_counting" data-showviewercount="' . ( $show_viewer_count ? '1' : '0' ) . '"></div>';
600 -
601 - $show_wpstream_not_live_mess = ' style="display:none;" ';
602 - if ( trim( $hls_playback_url ) == '' ) {
603 -
604 - $show_wpstream_not_live_mess = '';
605 - }
606 -
607 - $message_show = esc_html( get_option( 'wpstream_you_are_not_live', 'We are not live at this moment' ) );
608 -
609 - if ( function_exists( 'wpstream_theme_not_live_section' ) ) {
610 - print wpstream_theme_not_live_section( $channel_id );
611 - } else {
612 - print '<div class="wpstream_not_live_mess" ' . $show_wpstream_not_live_mess . ' style="display: none">
613 - <div class="wpstream_not_live_mess_back"></div>
614 - <div class="wpstream_not_live_mess_mess">' . esc_html( $message_show ) . '</div>
615 - </div>';
616 - }
617 -
618 -
619 - $poster_data = '';
620 - if ( isset( $thumb[0] ) ) {
621 - $poster_data = ' poster="' . $thumb[0] . '" ';
622 - }
623 - if ( $poster_show == 'no' ) {
624 - $poster_data = '';
625 - }
626 -
627 - $is_muted = false;
628 - if ( isset( $event_settings['mute'] ) && intval( $event_settings['mute'] ) == 1 ) {
629 - $is_muted = true;
630 - }
631 - // override $is_muted and $autoplay here - for testing
632 - // $autoplay = true;
633 - // $is_muted = false;
634 -
635 - $autoplay_str = $autoplay ? 'autoplay' : '';
636 - $is_muted_str = $is_muted ? 'muted' : '';
637 -
638 - // override trailer url here - for testing
639 - // $video_trailer = '';
640 - // $video_trailer = '/wp-content/uploads/2023/10/production-ID_4608975.mp4';
641 - // $video_trailer = '/wp-content/uploads/2023/10/ultrawide.mp4';
642 -
643 -
644 - $player_logo_position_data = $this->wpstream_get_player_logo_data( $channel_id );
645 - $player_logo_position = $player_logo_position_data['player_logo_position'];
646 - $player_logo_position_class = $player_logo_position_data['player_logo_position_class'];
647 - $player_logo_horizontal_position = $player_logo_position_data['player_logo_horizontal_position'];
648 -// echo'
649 -// <div class="wpstream-video-container">
650 -// <div id="wpstream-pre-load-spinner" class="wpstream-pre-load-spinner"></div>
651 -// <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.'>
652 -// </video>
653 -// </div>';
654 - echo '<div class="wpstream-pre-load-spinner"></div>';
655 - echo '
656 - <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 . '>
657 -
658 - </video>';
659 - if ( $video_trailer ) {
660 - print '<div class="wpstream_theme_trailer_wrapper">';
661 - print '<div id="' . esc_attr( $play_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_play_trailer">
662 - <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
663 - <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"/>
664 - </svg>
665 - ' . esc_html__( 'Play Trailer', 'wpstream' ) . '</div>';
666 - print '<div id="' . esc_attr( $mute_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_mute_trailer">
667 - <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
668 - <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"/>
669 - </svg>
670 -
671 - </div>';
672 - print '<div id="' . esc_attr( $unmute_trailer_button_element_id ) . '" style="display: none;" class="wpstream_video_on_demand_unmute_trailer">
673 - <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
674 - <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"/>
675 - </svg>
676 - </div>';
677 - print '</div>';
678 - }
679 - print '</div>';
680 -
681 -
682 - // Live player bootstrap is handled by wpstream-player-bootstrap.js.
683 -
684 -
685 - if ( $use_chat == "yes" ) {
686 - $this->wpstream_connect_to_chat( $channel_id );
687 - }
688 -
689 - usleep( 10000 );
690 - } else {
691 - $live_channel_frame_base = WPSTREAM_PLAYER . "/player/live?";
692 - $live_channel_id = get_post_meta( $channel_id, 'channelId', true );
693 -
694 - $local_event_options = get_option( 'wpstream_user_streaming_global_channel_options' );
695 - $wpstream_session_encryption = false;
696 - $wpstream_live_channel_lock_to_website = false;
697 - $wpstream_live_channel_autoplay = false;
698 -
699 - if ( isset( $local_event_options['ses_encrypt'] ) && intval( $local_event_options['ses_encrypt'] ) == 1 ) {
700 - $wpstream_session_encryption = true;
701 - }
702 - if ( isset( $local_event_options['domain_lock'] ) && intval( $local_event_options['domain_lock'] ) == 1 ) {
703 - $wpstream_live_channel_lock_to_website = true;
704 - }
705 - if ( isset( $local_event_options['autoplay'] ) && intval( $local_event_options['autoplay'] ) == 1 ) {
706 - $wpstream_live_channel_autoplay = true;
707 - }
708 -
709 - $wpstream_live_channel_validate_url = '';
710 - if ( $wpstream_session_encryption ) {
711 - $wpstream_live_channel_validate_url = esc_url_raw(
712 - apply_filters(
713 - 'wpstream_live_channel_validate_playback_session_url',
714 - $this->playback_session->wpstream_get_default_validate_playback_session_url(),
715 - $live_channel_id
716 - )
717 - );
718 - wp_localize_script(
719 - 'wpstream-player-controls',
720 - 'wpstreamLiveIframeSessionApi',
721 - array(
722 - 'requirePlaybackSession' => true,
723 - 'nonce' => wp_create_nonce( 'wpstream_playback_session_issue' ),
724 - 'productId' => (int) $channel_id,
725 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
726 - )
727 - );
728 - }
729 -
730 - $local_event_options = get_option( 'wpstream_user_streaming_global_channel_options' );
731 - $wpstream_live_channel_lock_to_website = 0;
732 - $wpstream_live_channel_encrypt = 0;
733 - $wpstream_live_channel_abr = 0;
734 - $wpstream_live_channel_muted = 0;
735 -
736 - if ( isset( $local_event_options['domain_lock'] ) && intval( $local_event_options['domain_lock'] ) == 1 ) {
737 - $wpstream_live_channel_lock_to_website = 1;
738 - }
739 - if ( isset( $local_event_options['encrypt'] ) && intval( $local_event_options['encrypt'] ) == 1 ) {
740 - $wpstream_live_channel_encrypt = 1;
741 - }
742 - if ( isset( $local_event_options['adaptive_bitrate'] ) && intval( $local_event_options['adaptive_bitrate'] ) == 1 ) {
743 - $wpstream_live_channel_abr = 1;
744 - }
745 - if ( isset( $local_event_options['mute'] ) && intval( $local_event_options['mute'] ) == 1 ) {
746 - $wpstream_live_channel_muted = 1;
747 - }
748 -
749 - $live_channel_embed_ancestor = '';
750 - if ( $wpstream_live_channel_lock_to_website ) {
751 - $live_channel_embed_ancestor = esc_url_raw(
752 - apply_filters(
753 - 'wpstream_live_channel_embed_ancestor',
754 - $this->wpstream_get_site_origin_for_embed(),
755 - $live_channel_id
756 - )
757 - );
758 - }
759 -
760 - $wpstream_live_channel_embed_key = $this->wpstream_generate_player_embed_key(
761 - $live_channel_id,
762 - $wpstream_live_channel_validate_url,
763 - $live_channel_embed_ancestor,
764 - $wpstream_live_channel_encrypt ? 'yes' : ''
765 - );
766 - if ( '' === $wpstream_live_channel_embed_key ) {
767 - $wpstream_live_channel_embed_key = (string) get_post_meta( $channel_id, 'embed_key', true );
768 - }
769 - $wpstream_live_channel_trailer_embed_key = $this->wpstream_generate_player_embed_key(
770 - $video_trailer,
771 - $wpstream_live_channel_validate_url,
772 - $live_channel_embed_ancestor,
773 - $wpstream_live_channel_encrypt ? 'yes' : ''
774 - );
775 -
776 - $wpstream_player_iframe_skin_slug = '';
777 - if ( preg_match( '/^vjs-theme-(city|fantasy|forest|sea)$/', $player_theme, $vod_iframe_skin_m ) ) {
778 - $wpstream_player_iframe_skin_slug = $vod_iframe_skin_m[1];
779 - }
780 - $wpstream_show_viewer_count = (
781 - ( isset( $event_settings['view_count'] ) && intval( $event_settings['view_count'] ) == 1 )
782 - || ! isset( $event_settings['view_count'] )
783 - );
784 -
785 - $wpstream_poster_image = get_the_post_thumbnail_url( $channel_id, 'full' );
786 -
787 - $wpstream_player_logo_data = $this->wpstream_get_player_logo_data( $channel_id );
788 - $wpstream_player_logo_image = $wpstream_player_logo_data['player_logo_src'];
789 -
790 - $live_channel_query_args = array_filter(
791 - array(
792 - 'channel' => $live_channel_id,
793 - 'posterImage' => $wpstream_poster_image,
794 - 'embedKey' => $wpstream_live_channel_embed_key,
795 - 'autoplay' => $wpstream_live_channel_autoplay ? true : '',
796 - 'startMuted' => (bool) $wpstream_live_channel_muted,
797 - 'viewerCountBadge' => $wpstream_show_viewer_count ? true : '',
798 - 'encrypt' => $wpstream_live_channel_encrypt ? true : '',
799 - 'abr' => $wpstream_live_channel_abr ? true : '',
800 - 'validatePlaybackSessionUrl' => $wpstream_live_channel_validate_url,
801 - 'embedAncestor' => $live_channel_embed_ancestor,
802 - 'skin' => $wpstream_player_iframe_skin_slug,
803 - 'logoImage' => $wpstream_player_logo_image,
804 - 'logoPosition' => $wpstream_player_logo_image ? $wpstream_player_logo_data['player_logo_position'] : '',
805 - 'logoOpacity' => $wpstream_player_logo_image ? $wpstream_player_logo_data['player_logo_opacity'] : '',
806 - 'isThemeActive' => get_template() == 'hello-wpstream',
807 - ),
808 - static function ( $v ) {
809 - return $v !== null && $v !== '';
810 - }
811 - );
812 -
813 - $live_channel_trailer_iframe_query_args = array_filter(
814 - array(
815 - 'video' => $video_trailer,
816 - 'embedKey' => $wpstream_live_channel_trailer_embed_key,
817 - 'skin' => $wpstream_player_iframe_skin_slug,
818 - 'startMuted' => (bool) $wpstream_live_channel_muted,
819 - 'encrypt' => $wpstream_live_channel_encrypt ? true : '',
820 - 'validatePlaybackSessionUrl' => $wpstream_live_channel_validate_url,
821 - 'embedAncestor' => $live_channel_embed_ancestor,
822 - ),
823 - static function ( $v ) {
824 - return $v !== null && $v !== '';
825 - }
826 - );
827 -
828 - echo '<div class="wpstream_player_iframe_wrap">';
829 - echo '<iframe id="playerFrame"
830 - class="wpstream_live_channel_iframe"
831 - title="' . esc_attr__( 'Embedded content', 'wpstream' ) . '"
832 - src="' . esc_url( add_query_arg( $live_channel_query_args, $live_channel_frame_base ) ) . '"
833 - data-wpstream-frame-role="content"
834 - allowfullscreen
835 - allow="autoplay; fullscreen">
836 - </iframe>';
837 - if ( $trailer_attachment_id && get_template() === 'hello-wpstream' ) {
838 - echo '<iframe id="playerFrameTrailer"
839 - class="wpstream_live_channel_iframe wpstream_live_channel_iframe_trailer"
840 - title="' . esc_attr__( 'Embedded trailer content', 'wpstream' ) . '"
841 - src="' . esc_url( add_query_arg( $live_channel_trailer_iframe_query_args, WPSTREAM_PLAYER . "/player/vod?" ) ) . '"
842 - data-wpstream-frame-role="trailer"
843 - allowfullscreen
844 - allow="autoplay; fullscreen"
845 - style="display:none;"
846 - aria-hidden="true"
847 - tabindex="-1">
848 - </iframe>';
849 - }
850 - echo '</div>';
851 -
852 - }
853 -
854 - }
855 -
856 -
857 -
858 -
859 -
860 427 /**
861 428 *
862 429 * Edited in 4.0
863 430 *
@@ -884,11 +451,14 @@
884 451 if(isset($event_status['status']) && $event_status['status']=='active'){
885 452 //live event
886 453 if(isset($event_status['sldp_playback_url'])){
887 454 $hls_playback_url = $event_status['sldp_playback_url'];
455 +
456 + $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
457 + $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
458 + $live_conect_views = $this->remove_http($live_conect_views);
888 459
889 460 }
890 - $live_conect_views = $this->wpstream_get_live_connect_uri($event_status, 'sldp_playback_url');
891 461 if(isset($event_status['chat_url'])){
892 462 $chat_url =$event_status['chat_url'];
893 463 }
894 464
@@ -898,18 +468,9 @@
898 468
899 469
900 470
901 471
902 - $low_latency_is_muted = ( isset($event_settings['mute']) && intval($event_settings['mute']) == 1 );
903 - $low_latency_autoplay = true;
904 - if ( isset($event_settings['autoplay']) && intval($event_settings['autoplay']) == 0 ) {
905 - $low_latency_autoplay = false;
906 - }
907 - $low_latency_content_uri = isset( $hls_playback_url ) ? trim( $hls_playback_url ) : '';
908 - $low_latency_chat_uri = isset( $chat_url ) ? trim( $chat_url ) : '';
909 - $low_latency_stats_uri = isset( $live_conect_views ) ? trim( $live_conect_views ) : '';
910 -
911 - 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' ) .'" > ';
472 + 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.'" > ';
912 473
913 474
914 475 if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){
915 476 echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
@@ -919,9 +480,9 @@
919 480 if(trim($hls_playback_url) ==''){
920 481 $show_wpstream_not_live_mess='';
921 482 }
922 483
923 - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ;
484 + $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment. Please check back later.')) ;
924 485 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>';
925 486
926 487
927 488 $poster_data=' poster="'.$thumb[0].'" ';
@@ -930,16 +491,16 @@
930 491 }
931 492
932 493
933 494 $is_muted='';
934 - if( $low_latency_is_muted ){
495 + if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
935 496 $is_muted=' muted ';
936 497 }
937 498
938 499
939 500 $autoplay='autoplay';
940 - if( !$low_latency_autoplay ){
941 - $autoplay='';
501 + if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
502 + $autoplay='no_autoplay';
942 503 }
943 504
944 505 echo'
945 506 <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
@@ -944,11 +505,33 @@
944 505 echo'
945 506 <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
946 507 </div>';
947 508
948 - // Low-latency player bootstrap is handled by wpstream-player-bootstrap.js.
509 + print '<script type="text/javascript">
510 + //<![CDATA[
511 + jQuery(document).ready(function(){
512 + var low_latencyid="wpstream-video'.$now.'";
513 + document.addEventListener("DOMContentLoaded", initPlayer(low_latencyid, "'.$hls_playback_url.'","'.$is_muted.'","'.$autoplay.'" ) ); ';
514 + print'});
515 + //]]>
516 + </script>';
517 +
949 518
950 519
520 + if(trim($hls_playback_url) ==''){
521 + // $show_wpstream_not_live_mess='';
522 + }else{
523 + print '<script type="text/javascript">
524 + //<![CDATA[
525 + jQuery(document).ready(function(){
526 + var player_wrapper = jQuery(".wpstream_live_player_wrapper");
527 + wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'");
528 + });
529 + //]]>
530 + </script>';
531 + }
532 +
533 +
951 534 if($use_chat=="yes"){
952 535 $this->wpstream_connect_to_chat($channel_id);
953 536 }
954 537
@@ -989,19 +572,23 @@
989 572 if(is_ssl()){
990 573 $domain_scheme='https';
991 574 }
992 575
993 -
994 - $wpstream_vod_domain_lock = intval( get_option('wpstream_vod_domain_lock','') ) ;
995 - $corsorigin='*';
996 - if($wpstream_vod_domain_lock !== 0 ){
576 + $corsorigin='';
577 + if( isset($local_event_options['vod_domain_lock']) ){
578 + if (intval( $local_event_options['vod_domain_lock']) ==0 ){
579 + $corsorigin='*';
580 + }
581 + }else{
582 + $corsorigin='*';
583 + }
584 +
585 + if($corsorigin!='*'){
997 586 $corsorigin=$domain_scheme.'://'.$domain['host'];
998 - }
587 + }
999 588
1000 -
1001 589 $is_encrypt="false";
1002 - $wpstream_vod_encrypt = intval( get_option('wpstream_vod_encrypt','') ) ;
1003 - if( intval( $wpstream_vod_encrypt ) ==1 ){
590 + if( isset($local_event_options['vod_encrypt']) && intval( $local_event_options['vod_encrypt']) ==1 ){
1004 591 $is_encrypt="true";
1005 592 }
1006 593
1007 594 $hlsKeysUrlPrefix = get_site_url().'?wpstream_voddrm=';
@@ -1014,15 +601,14 @@
1014 601 'corsOrigin' => $corsorigin,
1015 602 'encryptHls' => $encrypt,
1016 603 'hlsKeysUrlPrefix' => $hlsKeysUrlPrefix,
1017 604 'debugDrm' => $debugDrm,
1018 - 'embed' => true,
1019 605 );
1020 606
1021 607
1022 608 $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
1023 609 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
1024 -
610 +
1025 611 if($curl_response_decoded['success']){
1026 612 set_transient( $transient_name, $curl_response_decoded['hlsUrl'] ,300);
1027 613 $hls_to_return = $curl_response_decoded['hlsUrl'];
1028 614 if( isset($curl_response_decoded['hlsDecryptionKey']) && isset($curl_response_decoded['hlsDecryptionKeyIndex']) ){
@@ -1031,17 +617,9 @@
1031 617 }else{
1032 618 delete_post_meta($product_id,'hlsDecryptionKey');
1033 619 delete_post_meta($product_id,'hlsDecryptionKeyIndex');
1034 620 }
1035 -
1036 - if ( isset( $curl_response_decoded['video'] ) &&
1037 - isset( $curl_response_decoded['embedKey'] ) &&
1038 - isset( $curl_response_decoded['embedUrl'] )
1039 - ) {
1040 - update_post_meta( $product_id, 'wpstream_vod_video_data', trim( (string) $curl_response_decoded['video'] ) );
1041 - update_post_meta( $product_id, 'wpstream_vod_embed_key', trim( (string) $curl_response_decoded['embedKey'] ) );
1042 - update_post_meta( $product_id, 'wpstream_vod_embed_url', trim( (string) $curl_response_decoded['embedUrl'] ) );
1043 - }
621 +
1044 622 }else{
1045 623 return '';
1046 624 }
1047 625
@@ -1050,55 +628,11 @@
1050 628 return $hls_to_return;
1051 629
1052 630 }
1053 631
1054 - function wpstream_get_player_theme( $channel_id = null ) {
1055 - $player_theme = get_option('wpstream_video_player_theme');
1056 - $is_streamify_user = $this->wpstream_is_streamify_user( $channel_id );
1057 - if ( !empty($player_theme) && !$is_streamify_user ) {
1058 - $this->wpstream_enqueue_player_theme_style( $player_theme );
1059 - return 'vjs-theme-' . $player_theme;
1060 - }
1061 -
1062 - return '';
1063 - }
1064 -
1065 - function wpstream_enqueue_player_theme_style( $player_theme ) {
1066 - if ( $player_theme != 'default' ) {
1067 - 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');
1068 -
1069 - }
1070 - }
1071 -
1072 - /*
1073 - * Return data about the logo
1074 - */
1075 - private function wpstream_get_player_logo_data( $product_id ): array {
1076 - $player_logo_position = get_option( 'wpstream_player_logo_position', 'top-left' );
1077 - $player_logo_position_class = '';
1078 - $player_logo_horizontal_position = '';
1079 - if ( $player_logo_position && $player_logo_position != '' ) {
1080 - $player_logo_position_parts = explode( '-', $player_logo_position );
1081 - if ( isset( $player_logo_position_parts[0], $player_logo_position_parts[1] ) ) {
1082 - $player_logo_position_class = 'logo-' . $player_logo_position_parts[0];
1083 - $player_logo_horizontal_position = 'logo-' . $player_logo_position_parts[1];
1084 - }
1085 - }
1086 -
1087 - $player_logo_src = $this->wpstream_get_video_player_logo( $product_id );
1088 - $player_logo_opacity = intval( esc_html( get_option('wpstream_player_logo_opacity','100') ) ) / 100;
1089 -
1090 - return array(
1091 - 'player_logo_src' => $player_logo_src,
1092 - 'player_logo_position' => $player_logo_position,
1093 - 'player_logo_position_class' => $player_logo_position_class,
1094 - 'player_logo_horizontal_position' => $player_logo_horizontal_position,
1095 - 'player_logo_opacity' => $player_logo_opacity,
1096 - );
1097 - }
1098 -
1099 632
1100 633
634 +
1101 635 /**
1102 636 * VODPlayer uri details
1103 637 *
1104 638 * @author cretu
@@ -1112,13 +646,11 @@
1112 646 * 2 - free video encrypted
1113 647 * 3 - free video -not encrypted
1114 648 */
1115 649
1116 - $post_type = get_post_type($product_id);
1117 - $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
1118 - $video_path_final = '';
1119 - $video_type = '';
1120 - if( ( $post_type =='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
650 +
651 + $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
652 + if( ( get_post_type($product_id)=='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
1121 653
1122 654 /*
1123 655 * IF vide is encrypted- readed from vod,streaner
1124 656 *
@@ -1132,9 +664,9 @@
1132 664 }
1133 665 $video_path_final = $this->wpstream_request_video_on_demand_hls_player($video_path,$product_id);
1134 666
1135 667
1136 - }else if( $post_type =='wpstream_product_vod' && $free_video_type==3 ){
668 + }else if( get_post_type($product_id)=='wpstream_product_vod' && $free_video_type==3 ){
1137 669
1138 670 /* Video is unecrypted - read from local or youtube / vimeo
1139 671 */
1140 672
@@ -1139,17 +671,24 @@
1139 671 */
1140 672
1141 673 $video_type = 'video/mp4';
1142 674 $video_path_final=esc_html(get_post_meta($product_id, 'wpstream_free_video_external', true));
1143 - wp_enqueue_script('youtube.min');
675 +
676 + if (strpos($video_path_final, 'www.youtube') !== false) {
677 + $wpstream_data_setup= ' data-setup=\'{ "techOrder": ["youtube"], "sources": [{ "type": "video/youtube", "src": "'.$video_path_final.'"}] }\' ';
678 + $video_path_final='';
679 + }
680 + if (strpos($video_path_final, 'vimeo.com') !== false) {
681 + $wpstream_data_setup= ' data-setup=\'{"techOrder": ["vimeo"], "sources": [{ "type": "video/vimeo", "src": "'.$video_path_final.'"}], "vimeo": { "color": "#fbc51b"} }\' ';
682 + $video_path_final='';
683 + }
684 +
1144 685 }
1145 686
1146 - $return_array = array();
687 + $return_array=array();
1147 688 $return_array['video_path_final'] = $video_path_final;
1148 689 $return_array['wpstream_data_setup']= $wpstream_data_setup;
1149 690 $return_array['video_type'] = $video_type;
1150 - $return_array['free_video_type'] = $free_video_type;
1151 - $return_array['post_type'] = $post_type ;
1152 691 return $return_array;
1153 692 }
1154 693
1155 694
@@ -1160,405 +699,56 @@
1160 699 * @author cretu
1161 700 */
1162 701
1163 702 public function wpstream_video_on_demand_player($product_id){
1164 - wp_enqueue_script('video.min');
1165 - wp_enqueue_script('wpstream-player');
1166 - wp_enqueue_script( 'wpstream-player-controls' );
703 +
704 + $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id);
705 + $video_path_final = $uri_details['video_path_final'];
706 + $wpstream_data_setup = $uri_details['wpstream_data_setup'];
707 + $video_type = $uri_details['video_type'];
708 +
709 + $thumb_id = get_post_thumbnail_id($product_id);
710 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
711 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
712 +
713 + $poster_thumb = '';
714 + if(isset($thumb[0])){
715 + $poster_thumb=$thumb[0];
716 + }
1167 717
1168 - wp_localize_script(
1169 - 'wpstream-player-controls',
1170 - 'wpstreamLiveUiConfig',
1171 - $this->wpstream_get_player_i18n_config()
1172 - );
718 + $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true);
719 + $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true);
720 +
1173 721
1174 - $player_theme = $this->wpstream_get_player_theme( $product_id );
722 + $pack = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
723 +
724 +
725 + if(isset($pack['available_data_mb']) && $pack['available_data_mb']>0){
726 +
727 + if($video_path_final==''){
728 + print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>';
729 + }
730 +
731 + 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"
732 + poster="'.esc_url($poster_thumb).'" '.$wpstream_data_setup.'>
1175 733
1176 - $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id);
1177 - $video_path_final = $uri_details['video_path_final'];
1178 - $wpstream_data_setup = $uri_details['wpstream_data_setup'];
1179 - $video_type = $uri_details['video_type'];
1180 - $now = time().rand(0,1000000);
1181 -
1182 - $overlay_video_div_id = "random_id_".$now;
1183 - $this->wpstream_render_vod_title_overlay(
1184 - $overlay_video_div_id,
1185 - get_the_title($product_id)
1186 - );
1187 -
1188 - $thumb_id = get_post_thumbnail_id($product_id);
1189 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
1190 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
1191 -
1192 - $poster_thumb = '';
1193 - if(isset($thumb[0])){
1194 - $poster_thumb=$thumb[0];
1195 - }
1196 -
1197 - $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true);
1198 - $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true);
1199 -
1200 -
1201 - $pack = $this->main->quota_manager->get_live_quota_data( 'wpstream_video_on_demand_player' );
1202 -
1203 -
1204 -
1205 - $trailer_attachment_id = intval (get_post_meta( $product_id, 'video_trailer', true ));
1206 - $video_trailer = '';
1207 - $video_trailer_type = '';
1208 - if($trailer_attachment_id!=0) {
1209 - $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
1210 - $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
1211 - if( isset ($attachment_metadata['mime_type']) ) {
1212 - $video_trailer_type = $attachment_metadata['mime_type'];
1213 - }
1214 - }
1215 -
1216 - // override trailer setup here (for testing)
1217 - // $trailer_attachment_id = 1;
1218 - // $video_trailer = '/wp-content/uploads/2023/10/production-ID_4608975.mp4';
1219 - // $video_trailer = '/wp-content/uploads/2023/10/ultrawide.mp4';
1220 -
1221 - // If the video is self hosted or external, we should let the user see it
1222 - $video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
1223 -
1224 -
1225 - if ( $this->main->quota_manager->can_stream_vod( $pack ) || $video_type === 3 ) {
1226 -
1227 - if($video_path_final==''){
1228 - if( $uri_details['post_type']=='wpstream_product_vod' && $uri_details['free_video_type']==3 ){
734 + <source src="'.trim($video_path_final).'" type="'.$video_type.'">
735 + <p class="vjs-no-js">
736 + To view this video please enable JavaScript, and consider upgrading to a web browser that
737 + <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
738 + </p>
739 + </video>';
1229 740 }else{
1230 - print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>';
741 + print esc_html_e('Insufficient resources to stream this title','wpstream');
1231 742 }
1232 743
1233 - }
1234 -
1235 - // TODO (crerem) populate these from VOD settings
1236 - $autoplay = false;
1237 - $muted = false;
1238 -
1239 - $wpstream_vod_start_muted = intval ( get_option('wpstream_vod_start_muted','') );
1240 - if($wpstream_vod_start_muted===1){
1241 - $muted=true;
1242 - }
1243 - $wpstream_vod_autoplay = intval ( get_option('wpstream_vod_autoplay','') );
1244 - if($wpstream_vod_autoplay===1){
1245 - $autoplay=true;
1246 - }
1247 -
1248 - $poster_data = 'poster="'.esc_url($poster_thumb).'"';
1249 - $has_trailer_class='';
1250 - if($trailer_attachment_id !=0){
1251 - $poster_data=''; // cancel poster for theme
1252 - $has_trailer_class='wpstream_theme_player_has_trailer';
1253 - }
1254 -
1255 - $player_logo_data = $this->wpstream_get_player_logo_data( $product_id );
1256 - $player_logo_image = $player_logo_data['player_logo_src'];
1257 - $player_logo_position = $player_logo_data['player_logo_position'];
1258 - $player_logo_position_class = $player_logo_data['player_logo_position_class'];
1259 - $player_logo_horizontal_position = $player_logo_data['player_logo_horizontal_position'];
1260 - $player_logo_opacity = $player_logo_data['player_logo_opacity'];
1261 -
1262 - $captionsUrl = get_post_meta( $product_id, 'wpstream_closed_captions_file', true );
1263 - $play_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_play_trailer_btn_' . $now : '';
1264 - $mute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_mute_trailer_btn_' . $now : '';
1265 - $unmute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_unmute_trailer_btn_' . $now : '';
1266 - $play_video_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_play_video_btn_' . $now : '';
1267 -
1268 - $wpstream_vod_encrypt = intval( get_option( 'wpstream_vod_encrypt', '' ) );
1269 - $wpstream_vod_lock_to_website = intval( get_option( 'wpstream_vod_domain_lock', '' ) );
1270 -
1271 - $wpstream_session_encryption = 0;
1272 - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
1273 - if(isset($local_event_options['ses_encrypt']) && intval($local_event_options['ses_encrypt'])==1 ) {
1274 - $wpstream_session_encryption = 1;
1275 - }
1276 -
1277 - /**
1278 - * 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".
1279 - * Embed keys must be minted with the same inputs as the iframe query (video, validatePlaybackSessionUrl, embedAncestor, encrypt) per player embed-key.js.
1280 - *
1281 - * @see WPStream player embed-key.js and session-validation.js (verifyPlaybackSessionUrl).
1282 - */
1283 - $vod_validate_url = '';
1284 - if ( $wpstream_session_encryption ) {
1285 - $vod_validate_url = esc_url_raw(
1286 - apply_filters(
1287 - 'wpstream_vod_validate_playback_session_url',
1288 - $this->playback_session->wpstream_get_default_validate_playback_session_url(),
1289 - $product_id
1290 - )
1291 - );
1292 - wp_localize_script(
1293 - 'wpstream-player-controls',
1294 - 'wpstreamVodIframeSessionApi',
1295 - array(
1296 - 'requirePlaybackSession' => true,
1297 - 'nonce' => wp_create_nonce( 'wpstream_playback_session_issue' ),
1298 - 'productId' => (int) $product_id,
1299 - 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
1300 - )
1301 - );
1302 - }
1303 -
1304 - $vod_embed_ancestor = '';
1305 - if ( $wpstream_vod_lock_to_website ) {
1306 - $vod_embed_ancestor = esc_url_raw(
1307 - apply_filters(
1308 - 'wpstream_vod_embed_ancestor',
1309 - $this->wpstream_get_site_origin_for_embed(),
1310 - $product_id
1311 - )
1312 - );
1313 - }
1314 -
1315 - // if there's "wpstream_vod_embed_url" set, it means that we use the new player
1316 - $wpstream_vod_embed_url = get_post_meta( $product_id, 'wpstream_vod_embed_url', true );
1317 -
1318 - $vod_iframe_base = WPSTREAM_PLAYER . "/player/vod?";
1319 - $vod_iframe_video_raw = (string) get_post_meta( $product_id, 'wpstream_vod_video_data', true );
1320 - $vod_iframe_video = trim( $vod_iframe_video_raw );
1321 - if ( strlen( $vod_iframe_video ) >= 2 ) {
1322 - $first_char = $vod_iframe_video[0];
1323 - $last_char = substr( $vod_iframe_video, -1 );
1324 - $is_wrapped_in_double_quotes = '"' === $first_char && '"' === $last_char;
1325 - $is_wrapped_in_single_quotes = "'" === $first_char && "'" === $last_char;
1326 - if ( $is_wrapped_in_double_quotes || $is_wrapped_in_single_quotes ) {
1327 - $vod_iframe_video = substr( $vod_iframe_video, 1, -1 );
1328 - }
1329 - }
1330 - $vod_iframe_embed_key = $this->wpstream_generate_player_embed_key(
1331 - $vod_iframe_video,
1332 - $vod_validate_url,
1333 - $vod_embed_ancestor,
1334 - $wpstream_vod_encrypt ? 'yes' : ''
1335 - );
1336 - if ( '' === $vod_iframe_embed_key ) {
1337 - $vod_iframe_embed_key = (string) get_post_meta( $product_id, 'wpstream_vod_embed_key', true );
1338 - }
1339 - $vod_iframe_trailer_embed_key = $this->wpstream_generate_player_embed_key(
1340 - $video_trailer,
1341 - $vod_validate_url,
1342 - $vod_embed_ancestor,
1343 - $wpstream_vod_encrypt ? 'yes' : ''
1344 - );
1345 -
1346 - $vod_poster_image = get_the_post_thumbnail_url( $product_id, 'full' );
1347 - $current_active_theme = wp_get_theme();
1348 -
1349 - $vod_iframe_skin_slug = '';
1350 - if ( preg_match( '/^vjs-theme-(city|fantasy|forest|sea)$/', $player_theme, $vod_iframe_skin_m ) ) {
1351 - $vod_iframe_skin_slug = $vod_iframe_skin_m[1];
1352 - }
1353 -
1354 - $vod_iframe_query_args = array_filter(
1355 - array(
1356 - 'video' => $vod_iframe_video,
1357 - 'posterImage' => $vod_poster_image,
1358 - 'embedKey' => $vod_iframe_embed_key,
1359 - 'startMuted' => $muted ? '1' : '',
1360 - 'skin' => $vod_iframe_skin_slug,
1361 - 'encrypt' => $wpstream_vod_encrypt ? 'yes' : '',
1362 - 'validatePlaybackSessionUrl' => $vod_validate_url,
1363 - 'embedAncestor' => $vod_embed_ancestor,
1364 - 'logoImage' => $player_logo_image,
1365 - 'logoPosition' => $player_logo_image ? $player_logo_position : '',
1366 - 'logoOpacity' => $player_logo_image ? $player_logo_opacity : '',
1367 - 'isThemeActive' => $current_active_theme->get('Name') === 'Hello WPStream',
1368 - ),
1369 - static function ( $v ) {
1370 - return $v !== null && $v !== '';
1371 - }
1372 - );
1373 -
1374 - $vod_trailer_iframe_query_args = array_filter(
1375 - array(
1376 - 'video' => $video_trailer,
1377 - 'embedKey' => $vod_iframe_trailer_embed_key,
1378 - 'skin' => $vod_iframe_skin_slug,
1379 - 'startMuted' => $muted ? '1' : '',
1380 - 'encrypt' => $wpstream_vod_encrypt ? 'yes' : '',
1381 - 'validatePlaybackSessionUrl' => $vod_validate_url,
1382 - 'embedAncestor' => $vod_embed_ancestor,
1383 - ),
1384 - static function ( $v ) {
1385 - return $v !== null && $v !== '';
1386 - }
1387 - );
1388 -
1389 - if ( $wpstream_vod_embed_url ) {
1390 - echo '<div class="wpstream_player_iframe_wrap">';
1391 - echo '<iframe id="playerFrame"
1392 - class="wpstream_video_on_demand_iframe"
1393 - title="' . esc_attr__( 'Embedded content', 'wpstream' ) . '"
1394 - src="' . esc_url( add_query_arg( $vod_iframe_query_args, $vod_iframe_base ) ) . '"
1395 - data-wpstream-frame-role="content"
1396 - allowfullscreen
1397 - allow="autoplay; fullscreen">
1398 - </iframe>';
1399 - if ( $trailer_attachment_id != 0 && get_template() == 'hello-wpstream' ) {
1400 - echo '<iframe id="playerFrameTrailer"
1401 - class="wpstream_video_on_demand_iframe wpstream_video_on_demand_iframe_trailer"
1402 - title="' . esc_attr__( 'Embedded trailer content', 'wpstream' ) . '"
1403 - src="' . esc_url( add_query_arg( $vod_trailer_iframe_query_args, $vod_iframe_base ) ) . '"
1404 - data-wpstream-frame-role="trailer"
1405 - allowfullscreen
1406 - allow="autoplay; fullscreen"
1407 - style="display:none;"
1408 - aria-hidden="true"
1409 - tabindex="-1">
1410 - </iframe>';
1411 - }
1412 - echo '</div>';
1413 - } else {
1414 - 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"
1415 - '. $poster_data.' '.$wpstream_data_setup.'>
1416 - <p class="vjs-no-js">
1417 - To view this video please enable JavaScript, and consider upgrading to a web browser that
1418 - <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
1419 - </p>
1420 - </video>';
1421 -
1422 - if($trailer_attachment_id !=0){
1423 - print '<div class="wpstream_theme_trailer_wrapper">';
1424 - print '<div id="'.esc_attr( $play_trailer_button_element_id ).'" class="wpstream_video_on_demand_play_trailer">
1425 - <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1426 - <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"/>
1427 - </svg>
1428 - '.esc_html__('Play Trailer','wpstream').'</div>';
1429 -
1430 - print '<div class="wpstream_video_on_demand_play_video_wrapper" id="'.esc_attr( $play_video_button_element_id ).'" >
1431 - <div class="wpstream_video_on_demand_play_video">
1432 - <svg width="29" height="30" viewBox="0 0 29 30" fill="none" xmlns="http://www.w3.org/2000/svg">
1433 - <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"/>
1434 - </svg>
1435 - </div>
1436 - '.esc_html__('Play Video','wpstream').'
1437 - </div>';
1438 -
1439 -
1440 -
1441 - print '<div id="'.esc_attr( $mute_trailer_button_element_id ).'" class="wpstream_video_on_demand_mute_trailer">
1442 -
1443 - <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
1444 - <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"/>
1445 - </svg>
1446 - </div>';
1447 - print '<div id="'.esc_attr( $unmute_trailer_button_element_id ).'" class="wpstream_video_on_demand_unmute_trailer">
1448 - <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
1449 - <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"/>
1450 - </svg>
1451 -
1452 - </div>';
1453 - print '</div>';
1454 - }
1455 - }
1456 - }else{
1457 - print '<div class="wpstream_insuficent_res">'.esc_html__('Insufficient resources to stream this title','wpstream').'</div>';
1458 - }
1459 -
1460 744 }
1461 745
1462 746
1463 747
1464 - /**
1465 - * VODPlayer url - only trailer - used in theme
1466 - *
1467 - * @author cretu
1468 - */
1469 - public function wpstream_video_on_demand_player_only_trailer($product_id){
1470 - wp_enqueue_script('video.min');
1471 - wp_enqueue_script('wpstream-player');
1472 -
1473 - $player_theme = $this->wpstream_get_player_theme();
1474 - $now = time().rand(0,1000000);
1475 - $overlay_video_div_id = "random_id_".$now;
1476 - $this->wpstream_render_vod_title_overlay(
1477 - $overlay_video_div_id,
1478 - get_the_title($product_id)
1479 - );
1480 -
1481 -
1482 -
1483 - $thumb_id = get_post_thumbnail_id($product_id);
1484 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
1485 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
1486 -
1487 - $poster_thumb = '';
1488 - if(isset($thumb[0])){
1489 - $poster_thumb=$thumb[0];
1490 - }
1491 -
1492 -
1493 - $trailer_attachment_id = intval (get_post_meta( $product_id, 'video_trailer', true ));
1494 - $video_trailer = '';
1495 - $video_trailer_type = '';
1496 - if($trailer_attachment_id!=0) {
1497 - $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
1498 - $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
1499 - if(isset($attachment_metadata['mime_type'])){
1500 - $video_trailer_type = $attachment_metadata['mime_type'];
1501 - }
1502 -
1503 - }
1504 -
1505 -
1506 - $autoplay = false;
1507 - $muted = false;
1508 -
1509 - if( intval ( get_option('wpstream_vod_start_muted','') ) === 1){
1510 - $muted = true;
1511 - }
1512 - if( intval ( get_option('wpstream_vod_autoplay','') ) === 1 ){
1513 - $autoplay = true;
1514 - }
1515 - $video_path_final='';
1516 - $has_trailer_class='wpstream_theme_player_has_trailer';
1517 - $captions_url = get_post_meta( $product_id, 'wpstream_closed_captions_file', true );
1518 - $play_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_play_trailer_btn_' . $now : '';
1519 - $mute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_mute_trailer_btn_' . $now : '';
1520 - $unmute_trailer_button_element_id = $trailer_attachment_id != 0 ? 'wpstream_video_on_demand_unmute_trailer_btn_' . $now : '';
1521 -
1522 - 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"
1523 - >
1524 - <p class="vjs-no-js">
1525 - To view this video please enable JavaScript, and consider upgrading to a web browser that
1526 - <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
1527 - </p>
1528 - </video>';
1529 -
1530 - if($trailer_attachment_id !=0){
1531 - print '<div class="wpstream_theme_trailer_wrapper">';
1532 - print '<div id="'.esc_attr( $play_trailer_button_element_id ).'" class="wpstream_video_on_demand_play_trailer">
1533 - <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1534 - <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"/>
1535 - </svg>
1536 - '.esc_html__('Play Trailer','wpstream').'
1537 - </div>';
1538 - print '<div id="'.esc_attr( $mute_trailer_button_element_id ).'" class="wpstream_video_on_demand_mute_trailer">
1539 - <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
1540 - <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"/>
1541 - </svg>
1542 -
1543 -
1544 - </div>';
1545 - print '<div id="'.esc_attr( $unmute_trailer_button_element_id ).'" class="wpstream_video_on_demand_unmute_trailer">
1546 - <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
1547 - <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"/>
1548 - </svg>
1549 -
1550 - </div>';
1551 - print '</div>';
1552 - }
1553 - else {
1554 - //just show the poster or don't show anything; no player needed
1555 - }
1556 -
1557 - }
1558 -
1559 748
1560 749
750 +
1561 751 /**
1562 752 *
1563 753 * edited 4.0
1564 754 *
@@ -1569,119 +759,26 @@
1569 759 private function wpstream_retrive_username(){
1570 760
1571 761 return get_option('wpstream_api_username_from_token');
1572 762 }
1573 -
1574 - /**
1575 - * Render title overlay via action hook.
1576 - *
1577 - * @param string $overlay_id Overlay element id.
1578 - * @param string $title_text Title text.
1579 - */
1580 - private function wpstream_render_vod_title_overlay( $overlay_id, $title_text ) {
1581 - if ( has_action( 'wpstream_vod_title_overlay' ) ) {
1582 - do_action(
1583 - 'wpstream_vod_title_overlay',
1584 - $overlay_id,
1585 - $title_text,
1586 - esc_html__( 'Playing:', 'wpstream' )
1587 - );
1588 - }
1589 - }
1590 763
1591 - /**
1592 - * check if the we can add display the player
1593 - *
1594 - * @since 3.12
1595 - * returns html of the player
1596 - */
764 + /**
765 + * check if the we can add display the player
766 + *
767 + * @since 3.12
768 + * returns html of the player
769 + */
1597 770
1598 - public function wpstream_check_if_player_can_dsplay($product_id){
1599 - if ( is_user_logged_in() ) {
1600 -
1601 - $term_list = wp_get_post_terms($product_id, 'product_type');
1602 - $current_user = wp_get_current_user();
1603 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1604 -
1605 - $product = wc_get_product($product_id);
1606 - $product_type = $product->get_type();
1607 -
1608 -
1609 - if($subscription_model==1){ // if we have Neflix mode
1610 - if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
1611 - return false;
1612 - }
1613 - if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
1614 - return true;
1615 - }
1616 - }else{
1617 - // ppv mode
771 + public function wpstream_check_if_player_can_dsplay($product_id){
772 + if ( is_user_logged_in() ) {
1618 773
1619 - if( $product_type=='subscription' ){
1620 -
1621 -// $user_subscriptions = wcs_get_users_subscriptions($current_user->ID );
1622 -// foreach ($user_subscriptions as $subscription) {
1623 -// $subscription_status = $subscription->get_status();
1624 -// echo "</br>*** Subscription ID $subscription->ID for User ID $current_user->ID has status: $subscription_status";
1625 -// }
1626 -
1627 -
1628 - if( wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
1629 - // user has active subcription
1630 - return true;
1631 - }
774 + $term_list = wp_get_post_terms($product_id, 'product_type');
775 + $current_user = wp_get_current_user();
776 + $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1632 777
1633 - }else{
1634 - if( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id)){
1635 - return true;
1636 - }
1637 - }
1638 -
1639 -
1640 - }
1641 - return false;
1642 -
1643 - }
1644 - return false;
1645 -
1646 - }
1647 -
1648 -
1649 -
1650 - /**
1651 - * check if the we can add display the player - theme variant
1652 - *
1653 - * @since 3.12
1654 - * returns html of the player
1655 - */
1656 - public function wpstream_check_if_player_can_dsplay_theme($product_id){
1657 -
1658 - $post_type= get_post_type($product_id);
1659 -
1660 -
1661 -
1662 - if($post_type=='wpstream_product_vod' || $post_type=='wpstream_product'){
1663 - return true; // if we have free vod or live
1664 - }
1665 -
1666 -
1667 -
1668 - if ( is_user_logged_in() && $post_type==='product' ) {
1669 778
1670 - $product = wc_get_product( $product_id );
1671 - $product_type = $product->get_type();
1672 - $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle',true);
1673 -
1674 -
1675 -
1676 -
1677 -
1678 - $current_user = wp_get_current_user();
1679 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1680 - // print 'subscription model '.$subscription_model.'</br>';
1681 -
1682 779 if($subscription_model==1){ // if we have Neflix mode
1683 - if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
780 + if( $term_list[0]->name=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
1684 781 return false;
1685 782 }
1686 783 if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
1687 784 return true;
@@ -1687,20 +784,13 @@
1687 784 return true;
1688 785 }
1689 786 }else{
1690 787 // ppv mode
1691 - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ){
1692 - return true; //simple product bought
1693 - }else if (function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ){
1694 - return true; // subscription boght
1695 - }else if( get_post_type($product_id) =='product' &&
1696 - intval($possible_bundle )!=0 &&
1697 - wc_customer_bought_product( $current_user->user_email, $current_user->ID, $possible_bundle)
1698 - ){
1699 - return true; // part of a boght bundle
788 + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ||
789 + ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){
790 + return true;
1700 791 }
1701 792 }
1702 - // print ' fac return false </br>';
1703 793 return false;
1704 794
1705 795 }
1706 796 return false;
@@ -1707,14 +797,15 @@
1707 797
1708 798 }
1709 799
1710 800
801 +
1711 802 /**
1712 - * in plugin - check if global subscription model is enabled
1713 - *
1714 - * @since 3.12
803 + * in plugin - check if global subscription model is enabled
804 + *
805 + * @since 3.12
1715 806 *
1716 - */
807 + */
1717 808 public function wpstream_in_plugin_check_global_subscription_model($product_id) {
1718 809
1719 810 // $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
1720 811 if( is_user_logged_in() && function_exists('wcs_user_has_subscription') ){
@@ -1721,9 +812,9 @@
1721 812
1722 813 global $woocommerce;
1723 814 $current_user = wp_get_current_user();
1724 815
1725 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
816 + $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1726 817 $main_subscription = intval( get_option('wpstream_global_sub_id',''));
1727 818
1728 819 if($subscription_model==1){
1729 820 $selected_sub= get_post_meta($product_id,'_wpstream_parent_sub',true) ;
@@ -1766,11 +857,11 @@
1766 857 *
1767 858 *
1768 859 *
1769 860 *
1770 - * check if the user bought the product and display the player - TO REDo
1771 - *
1772 - * @since 3.0.1
861 + * check if the user bought the product and display the player - TO REDo
862 + *
863 + * @since 3.0.1
1773 864 * returns html of the player
1774 865 *
1775 866 *
1776 867 *
@@ -1775,48 +866,38 @@
1775 866 *
1776 867 *
1777 868 *
1778 869 *
1779 - */
870 + */
1780 871 public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
1781 - if(function_exists('wpstream_remove_wpstream_filter')){
1782 - return;
1783 - }
1784 872 global $product;
1785 - $product_id = $product->get_id();
1786 - $current_user = wp_get_current_user();
1787 - $term_list = wp_get_post_terms($product_id, 'product_type');
1788 -
1789 - $is_simple_subscription = get_post_meta($product_id, '_subscript_live_event');
1790 - if ( $term_list[0]->name == 'subscription' && ! empty( $is_simple_subscription ) && $is_simple_subscription[0] == 'none' ) {
1791 - return;
1792 - }
1793 -
873 + $product_id = $product->get_id();
874 + $current_user = wp_get_current_user();
1794 875 if ( is_user_logged_in() ) {
876 +
1795 877 if($this->wpstream_check_if_player_can_dsplay($product_id) ){
1796 -
878 +
1797 879 echo '<div class="wpstream_player_wrapper "><div class="wpstream_player_container">';
1798 880
1799 881 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
1800 -
882 + $term_list = wp_get_post_terms($product_id, 'product_type');
1801 883
1802 884
1803 885 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
1804 886 $this->wpstream_live_event_player($product_id);
1805 887 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
1806 -
1807 888 $this->wpstream_video_on_demand_player($product_id);
1808 889 }
1809 890 echo '</div></div>';
1810 - } else {
1811 - if( $term_list[0]->name=='subscription' ){
1812 -
891 + }else{
892 +
893 +
894 + $term_list = wp_get_post_terms($product_id, 'product_type');
895 + if( $term_list[0]->name=='subscription' ){
1813 896 if( !wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
1814 897 $this->wpstream_display_no_buy_message('nobuy',$product_id);
1815 898 }
1816 899
1817 - }else{
1818 - $this->wpstream_display_no_buy_message('nobuy',$product_id);
1819 900 }
1820 901
1821 902
1822 903
@@ -1835,13 +916,13 @@
1835 916
1836 917 /**
1837 918 *
1838 919 *
1839 - * check if the user bought the product and display the player - TO REDo
1840 - *
1841 - * @since 3.0.1
920 + * check if the user bought the product and display the player - TO REDo
921 + *
922 + * @since 3.0.1
1842 923 * returns html of the player
1843 - */
924 + */
1844 925
1845 926 public function wpstream_chat_wrapper($product_id){
1846 927 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/templates/wpstream_chat_template.php';
1847 928 }
@@ -1853,13 +934,13 @@
1853 934
1854 935
1855 936
1856 937 /**
1857 - * coonect to chat
1858 - *
1859 - * @since 1.12.2
938 + * coonect to chat
939 + *
940 + * @since 1.12.2
1860 941 *
1861 - */
942 + */
1862 943
1863 944
1864 945
1865 946 public function wpstream_connect_to_chat($product_id){
@@ -1908,15 +989,15 @@
1908 989 }
1909 990
1910 991
1911 992 /**
1912 - * display no buy Message
1913 - *
1914 - * @since 3.12.2
993 + * display no buy Message
994 + *
995 + * @since 3.12.2
1915 996 *
1916 - */
997 + */
1917 998 public function wpstream_display_no_buy_message($log,$product_id) {
1918 -
999 +
1919 1000 if($log=='sub_active'){
1920 1001 $message= esc_html( get_option('wpstream_subscription_active','Your Subscription is Active.')) ;
1921 1002 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1922 1003 echo '<div class="wpstream_notice"> '.$message.'</div>';
@@ -1927,9 +1008,9 @@
1927 1008 $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
1928 1009 }else{
1929 1010 $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
1930 1011 }
1931 - $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1012 + $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1932 1013 if($subscription_model==1){
1933 1014 $message =esc_html( get_option('wpstream_product_not_subscribe','You did not yet subscribe to this item.'));
1934 1015 }
1935 1016
@@ -1934,16 +1015,11 @@
1934 1015 }
1935 1016
1936 1017
1937 1018 if( get_post_type($product_id) == 'product' && $subscription_model==0 ){
1938 - $product = wc_get_product($product_id);
1939 - $term_list = wp_get_post_terms($product_id, 'product_type');
1940 - $product_type = $product->get_type();
1941 - $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
1942 -
1943 1019
1944 -
1945 - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream' || $product_type=='subscription'){
1020 + $term_list = wp_get_post_terms($product_id, 'product_type');
1021 + if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
1946 1022
1947 1023 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1948 1024 echo '<div class="wpstream_notice">'.$message.'</div>';
1949 1025 echo '</div></div>';
@@ -1950,66 +1026,18 @@
1950 1026
1951 1027 }
1952 1028
1953 1029 }else if( get_post_type($product_id) == 'product' && $subscription_model==1 ){
1954 - $term_list = wp_get_post_terms($product_id, 'product_type');
1955 - if( $term_list[0]->name!=='simple'){
1956 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1957 - echo '<div class="wpstream_notice"> '.$message.'</div>';
1958 - echo '</div></div>';
1959 - }
1030 + echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1031 + echo '<div class="wpstream_notice"> '.$message.'</div>';
1032 + echo '</div></div>';
1960 1033 }
1034 +
1035 +
1036 +
1037 +
1038 +
1039 +
1961 1040 }
1962 -
1963 - /**
1964 - * Get the video player logo URL.
1965 - *
1966 - * @param int $product_id Product ID.
1967 - * @return mixed|string
1968 - */
1969 - public function wpstream_get_video_player_logo( $product_id ) {
1970 - $is_streamify_user = $this->wpstream_is_streamify_user( $product_id );
1971 - if ( $is_streamify_user ) {
1972 - return WPSTREAM_PLUGIN_DIR_URL . 'img/wpstream-symbol-large.png';
1973 - }
1974 -
1975 - $logo = get_option( 'wpstream_player_logo', '' );
1976 - if ( ! empty( $logo ) ) {
1977 - return $logo;
1978 - }
1979 -
1980 - return '';
1981 - }
1982 -
1983 - /**
1984 - * Get cached pack data or request fresh pack data
1985 - *
1986 - * @param bool $force_refresh Force a refresh of the cached data
1987 - * @return array Pack data
1988 - */
1989 - private function wpstream_get_cached_pack_data( $force_refresh = false ) {
1990 - $cached_data = get_transient( 'wpstream_user_pack_data' );
1991 -
1992 - if ( $force_refresh || $cached_data === false ) {
1993 - $fresh_data = $this->main->user_quota_service->request_pack_data_per_user( 'wpstream_get_cached_pack_data' );
1994 - set_transient( 'wpstream_user_pack_data', $fresh_data, 60);
1995 -
1996 - return $fresh_data;
1997 - }
1998 -
1999 - return $cached_data;
2000 - }
2001 -
2002 - /*
2003 - * Check if the user is on a basic subscription
2004 - *
2005 - * @param int $channel_id Channel ID
2006 - * @return bool
2007 - */
2008 - public function wpstream_is_streamify_user( $channel_id ) {
2009 - $is_basic_streaming = get_post_meta( $channel_id, 'basicStreaming', true );
2010 - if ( $is_basic_streaming === '1' ) {
2011 - return true;
2012 - }
2013 - return false;
2014 - }
1041 +
1042 +
2015 1043 }