PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8.2
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8.2
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 +775 -238 4.4.54.8.2 View file →
@@ -12,8 +12,10 @@
12 12 *
13 13 * @author cretu
14 14 */
15 15 class Wpstream_Player{
16 + public $main;
17 +
16 18 public function __construct($plugin_main) {
17 19 $this->main = $plugin_main;
18 20
19 21 add_filter( 'the_content',array($this, 'wpstream_filter_the_title') );
@@ -20,13 +22,9 @@
20 22 add_action( 'woocommerce_before_single_product', array($this,'wpstream_user_logged_in_product_already_bought') );
21 23
22 24 add_action( 'wp_ajax_wpstream_player_check_status', array($this,'wpstream_player_check_status') );
23 25 add_action('wp_ajax_nopriv_wpstream_player_check_status', array($this,'wpstream_player_check_status'));
24 -
25 -
26 -
27 -
28 -
26 +
29 27 }
30 28
31 29
32 30
@@ -49,21 +47,25 @@
49 47 $transient_name = 'event_data_to_return_'. $channel_id;
50 48 $event_data_for_transient = get_transient( $transient_name );
51 49
52 50
53 -
54 - if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
55 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id);
51 + $usefull_info =' get cache from transiet';
52 + if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
53 + $notes = 'wpstream_player_check_status_note_from_js';
54 + $event_status = $this->main->wpstream_live_connection->wpstream_check_event_status_api_call($channel_id,$notes);
56 55 $event_data_for_transient = $event_status;
57 -
56 + $usefull_info =' no cache found';
58 57 set_transient($transient_name,$event_data_for_transient,45);
59 58 }
60 59
61 60
62 61 if( isset($event_data_for_transient['hls_playback_url']) && $event_data_for_transient['hls_playback_url']!=''){
62 + // cleanup any previous echo before sending json
63 + ob_end_clean();
63 64 echo json_encode( array(
64 65
65 66 'started' => 'yes',
67 + 'usefull_info' => $usefull_info,
66 68 'channel_id' => $channel_id,
67 69 'event_uri' => $event_data_for_transient['hls_playback_url'],
68 70 'live_conect_views' => $event_data_for_transient['stats_url'],
69 71 'chat_url' => $event_data_for_transient['chat_url'],
@@ -70,20 +72,25 @@
70 72 '$event_data_for_transient'=>$event_data_for_transient
71 73
72 74
73 75 ));
76 + $usedfull_info =' ';
74 77 update_post_meta($channel_id,'stream_name',$event_data_for_transient['stream_name']);
75 78 update_post_meta($channel_id,'hls_key_retrieval_url',$event_data_for_transient['hls_key_retrieval_url']);
76 79 delete_transient( 'free_event_streamName_'.$event_data_for_transient['stream_name']);
77 80
78 81 }else{
82 + // cleanup any previous echo before sending json
83 + ob_end_clean();
79 84 echo json_encode( array(
80 85 'started' => 'no',
86 + 'usefull_info' => $usefull_info,
81 87 'server_id' => '',
82 - 'channel_id' => $channel_id,
88 + 'channel_id' => $channel_id,
83 89 'event_uri' => '',
84 90 'live_conect_views' => '',
85 91 'chat_url' => '',
92 +
86 93
87 94 ));
88 95
89 96 }
@@ -98,8 +105,12 @@
98 105 *
99 106 * @author cretu
100 107 */
101 108 public function wpstream_filter_the_title( $content ) {
109 + if(function_exists('wpstream_remove_wpstream_filter')){
110 + return $content;
111 + }
112 +
102 113 if( is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){
103 114 global $post;
104 115 $args=array('id'=>$post->ID);
105 116 $custom_content = $this->wpstream_insert_player_inpage($args);
@@ -152,22 +163,27 @@
152 163 */
153 164
154 165 public function wpstream_video_player_shortcode($from_sh_id='') {
155 166
156 -
167 + wp_enqueue_script('video.min');
168 + wp_enqueue_script('wpstream-player');
157 169
158 170 if ( is_user_logged_in() ) {
159 171 global $product;
160 172 $current_user = wp_get_current_user();
161 173 $product_id = intval($from_sh_id);
162 - $term_list = wp_get_post_terms($product_id, 'product_type');
163 -
174 + $term_list = wp_get_post_terms($product_id, 'product_type');
175 + $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle', true);
164 176
165 177
166 178
167 179
168 - 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) )
169 - || get_post_type($product_id)=='wpstream_product' || get_post_type($product_id)=='wpstream_product_vod' ){
180 + if (
181 +
182 + ( 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) ) ||
183 + ( 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) ) ||
184 + get_post_type($product_id)=='wpstream_product' ||
185 + get_post_type($product_id)=='wpstream_product_vod' ){
170 186 global $product;
171 187 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
172 188
173 189
@@ -191,9 +207,10 @@
191 207 }else{
192 208
193 209 if( get_post_type($product_id) == 'product' ){
194 210 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
195 - echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
211 + $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
212 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>';
196 213 echo '</div></div>';
197 214 }
198 215 }
199 216
@@ -200,12 +217,26 @@
200 217
201 218 }else{
202 219
203 220 $product_id = intval($from_sh_id);
204 - if( get_post_type($product_id) == 'wpstream_product' ){
205 - $this->wpstream_live_event_player($product_id);
221 + $term_list = wp_get_post_terms($product_id, 'product_type');
222 +
223 + if( get_post_type($product_id) == 'product' && ($term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand') ){
224 +
225 + echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
226 + $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
227 +
228 +
229 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>';
230 + echo '</div></div>';
231 + }elseif( get_post_type($product_id) == 'wpstream_product' ){
232 + echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
233 + $this->wpstream_live_event_player($product_id);
234 + echo '</div></div>';
206 235 } else if( get_post_type($product_id) == 'wpstream_product_vod' ){
207 - $this->wpstream_video_on_demand_player($product_id);
236 + echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
237 + $this->wpstream_video_on_demand_player($product_id);
238 + echo '</div></div>';
208 239 }
209 240 }
210 241 }
211 242
@@ -217,9 +248,12 @@
217 248 * @author cretu
218 249 */
219 250
220 251 public function wpstream_video_player_shortcode_low_latency($from_sh_id='') {
252 + wp_enqueue_script('video.min');
253 + wp_enqueue_script('wpstream-player');
221 254
255 +
222 256 if ( is_user_logged_in() ) {
223 257 global $product;
224 258 $current_user = wp_get_current_user();
225 259 $product_id = intval($from_sh_id);
@@ -246,9 +280,11 @@
246 280 }else{
247 281
248 282 if( get_post_type($product_id) == 'product' ){
249 283 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
250 - echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
284 +
285 + $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
286 + echo '<div class="wpstream_notice" style="background:#e16767;">'.$message.'</div>';
251 287 echo '</div></div>';
252 288 }
253 289 }
254 290
@@ -287,10 +323,13 @@
287 323 */
288 324
289 325 function wpestream_return_event_settings($product_id){
290 326
291 - $local_event_options = get_post_meta($product_id,'local_event_options',true);
292 - if(!is_array($local_event_options)){
327 + $local_event_options = get_post_meta( $product_id, 'local_event_options', true);
328 + $use_global_event_options = get_post_meta($product_id, 'use_global_event_options',true);
329 + $is_local_event_options_enabled = is_array( $local_event_options ) || intval( $use_global_event_options ) === 1;
330 +
331 + if( !$is_local_event_options_enabled ) {
293 332 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
294 333 }
295 334
296 335 return $local_event_options;
@@ -306,120 +345,206 @@
306 345 * @author cretu
307 346 */
308 347
309 348 function wpstream_live_event_player($channel_id,$poster_show='',$use_chat=''){
310 -
311 - $now = time().rand(0,1000000);
312 - $thumb_id = get_post_thumbnail_id($channel_id);
313 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
314 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
315 - $autoplay = 'autoplay';
316 -
317 - $event_settings = $this->wpestream_return_event_settings($channel_id);
318 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id);
319 - $hls_playback_url = '';
320 - $live_conect_views = '';
321 -
322 - if(isset($event_status['status']) && $event_status['status']=='active'){
323 - //live event
324 - if(isset($event_status['hls_playback_url'])){
325 - $hls_playback_url = $event_status['hls_playback_url'];
326 -
327 - update_post_meta($channel_id,'stream_name',$event_status['stream_name']);
328 - update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']);
329 - delete_transient( 'free_event_streamName_'.$event_status['stream_name']);
349 + wp_enqueue_script('video.min');
350 + wp_enqueue_script('wpstream-player');
330 351
331 - $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
332 - $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
333 - $live_conect_views = $this->remove_http($live_conect_views);
334 -
335 - }
336 - if(isset($event_status['chat_url'])){
337 - $chat_url = $event_status['chat_url'];
338 - }
339 -
340 - }else{
341 - // event not live
352 +
353 + $player_theme = $this->wpstream_get_player_theme();
354 + $now = time().rand(0,1000000);
355 + $overlay_video_div_id = "random_id_".$now;
356 + // 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>';
357 +
358 +
359 + $thumb_id = get_post_thumbnail_id($channel_id);
360 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
361 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
362 + $autoplay = true;
363 +
364 + $event_settings = $this->wpestream_return_event_settings($channel_id);
365 +
366 + $transient_name = 'event_data_to_return_'. $channel_id;
367 + $event_status = get_transient( $transient_name );
368 +
369 + if ( false === $event_status || $event_status=='' ) {
370 + $notes = 'wpstream_live_event_player_note';
371 + $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
372 + set_transient($transient_name, $event_status, 45);
373 + }
374 +
375 + $hls_playback_url = '';
376 + $live_conect_views = '';
377 +
378 + if(isset($event_status['status']) && $event_status['status']=='active'){
379 + //live event
380 + if(isset($event_status['hls_playback_url'])){
381 + $hls_playback_url = $event_status['hls_playback_url'];
382 +
383 + update_post_meta($channel_id,'stream_name',$event_status['stream_name']);
384 + update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']);
385 + delete_transient( 'free_event_streamName_'.$event_status['stream_name']);
386 +
387 + $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
388 + $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
389 + $live_conect_views = $this->remove_http($live_conect_views);
390 +
342 391 }
343 -
344 -
345 -
346 -
347 -
392 + if(isset($event_status['chat_url'])){
393 + $chat_url = $event_status['chat_url'];
394 + }
395 +
396 + }else{
397 + // event not live
398 + }
399 +
400 + if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
401 + $autoplay=false;
402 + }
403 +
404 +
405 +
406 + 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.'" > ';
407 +
408 + $show_viewer_count = (
409 + ( isset($event_settings['view_count']) && intval($event_settings['view_count']) == 1 )
410 + || !isset($event_settings['view_count'])
411 + );
412 +
413 + echo '<div id="wpestream_live_counting" class="wpestream_live_counting" data-showviewercount="' . ($show_viewer_count ? '1' : '0') . '"></div>';
414 +
415 + $show_wpstream_not_live_mess=' style="display:none;" ';
416 + if(trim($hls_playback_url) ==''){
417 +
418 + $show_wpstream_not_live_mess='';
419 + }
348 420
421 + $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ;
422 +
423 + if( function_exists('wpstream_theme_not_live_section' ) ) {
424 + print wpstream_theme_not_live_section( $channel_id );
425 + } else {
426 + print '<div class="wpstream_not_live_mess" '.$show_wpstream_not_live_mess.' style="display: none">
427 + <div class="wpstream_not_live_mess_back"></div>
428 + <div class="wpstream_not_live_mess_mess">'.esc_html($message_show).'</div>
429 + </div>';
430 + }
349 431
350 - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
351 - $autoplay='no_autoplay';
432 +
433 + $poster_data='';
434 + if(isset($thumb[0])){
435 + $poster_data=' poster="'.$thumb[0].'" ';
352 436 }
353 -
354 - 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.'" > ';
355 -
356 - if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){
357 - echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
437 + if($poster_show=='no'){
438 + $poster_data='';
439 + }
440 +
441 + $is_muted=false;
442 + if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
443 + $is_muted=true;
444 + }
445 + // override $is_muted and $autoplay here - for testing
446 + // $autoplay = true;
447 + // $is_muted = false;
448 +
449 + $autoplay_str = $autoplay ? 'autoplay' : '';
450 + $is_muted_str = $is_muted ? 'muted' : '';
451 +
452 + $video_trailer = '';
453 + $trailer_attachment_id = intval (get_post_meta( $channel_id, 'video_trailer', true ));
454 + $video_trailer = '';
455 + $video_trailer_type = '';
456 + $has_trailer_class = '';
457 + if($trailer_attachment_id!=0) {
458 + $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
459 + $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
460 + if( isset ($attachment_metadata['mime_type']) ) {
461 + $video_trailer_type = $attachment_metadata['mime_type'];
358 462 }
463 + $poster_data=''; // cancel poster for theme
464 + $has_trailer_class='wpstream_theme_player_has_trailer';
465 + }
466 +
467 + // override trailer url here - for testing
468 + // $video_trailer = '';
469 + // $video_trailer = '/wp-content/uploads/2023/10/production-ID_4608975.mp4';
470 + // $video_trailer = '/wp-content/uploads/2023/10/ultrawide.mp4';
471 +
472 +
473 +
474 + $player_logo_position = get_option('wpstream_player_logo_position');
475 + $player_logo_position_class = '';
476 + if( $player_logo_position && $player_logo_position != '' ){
477 + $player_logo_position_class = 'logo-' . explode( '-', $player_logo_position )[0];
478 + }
479 + echo'
480 + <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 .'" playsinline="true" '.$is_muted_str." ".$autoplay_str.'>
359 481
360 - $show_wpstream_not_live_mess=' style="display:none;" ';
361 - if(trim($hls_playback_url) ==''){
482 + </video>';
483 + if ($video_trailer){
484 + print '<div class="wpstream_theme_trailer_wrapper">';
485 + print '<div id="wpstream_live_video_play_trailer_btn_' . $now . '" style="display: none;" class="wpstream_video_on_demand_play_trailer">
486 + <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
487 + <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"/>
488 + </svg>
489 + '.esc_html__('Play Trailer', 'wpstream').'</div>';
490 + print '<div id="wpstream_live_video_mute_trailer_btn_' . $now . '" style="display: none;" class="wpstream_video_on_demand_mute_trailer">
491 + <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
492 + <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"/>
493 + </svg>
362 494
363 - $show_wpstream_not_live_mess='';
495 + </div>';
496 + print '<div id="wpstream_live_video_unmute_trailer_btn_' . $now . '" style="display: none;" class="wpstream_video_on_demand_unmute_trailer">
497 + <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
498 + <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"/>
499 + </svg>
500 + </div>';
501 + print '</div>';
364 502 }
365 -
366 -
367 - print '<div class="wpstream_not_live_mess" '.$show_wpstream_not_live_mess.'><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'.esc_html__('We are not live at this moment. Please check back later.','wpstream').'</div></div>';
368 -
369 - $poster_data='';
370 - if(isset($thumb[0])){
371 - $poster_data=' poster="'.$thumb[0].'" ';
372 - }
373 - if($poster_show=='no'){
374 - $poster_data='';
375 - }
503 + print '<script type="text/javascript">
504 + //<![CDATA[
505 + jQuery(document).ready(function(){
506 + wpstream_player_initialize({
507 + titleOverlayElementId:"'.$overlay_video_div_id.'",
508 + videoElementId: "'.$now.'",
509 + trailerUrl: "'.$video_trailer.'",
510 + contentUrl: "'.$hls_playback_url.'",
511 + statsUri: "'.$live_conect_views.'",
512 + autoplay: '.var_export($autoplay, true).',
513 + muted: '.var_export($is_muted, true).',
514 + playTrailerButtonElementId: "wpstream_live_video_play_trailer_btn_'.$now.'",
515 + muteTrailerButtonElementId: "wpstream_live_video_mute_trailer_btn_'.$now.'",
516 + unmuteTrailerButtonElementId: "wpstream_live_video_unmute_trailer_btn_'.$now.'",
517 + });
518 + });
519 + //]]>
520 + </script>';
521 + print '</div>';
522 +
523 +
524 + if(trim($hls_playback_url) ==''){
525 + // $show_wpstream_not_live_mess='';
526 + }else{
527 + print '<script type="text/javascript">
528 + //<![CDATA[
529 + jQuery(document).ready(function(){
530 + var player_wrapper = jQuery(".wpstream_live_player_wrapper");
531 + wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'");
532 + });
533 + //]]>
534 + </script>';
535 + }
536 +
537 +
538 + if($use_chat=="yes"){
539 + $this->wpstream_connect_to_chat($channel_id);
540 + }
541 +
542 + usleep (10000);
376 543
377 - $is_muted='';
378 - if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
379 - $is_muted=' muted ';
380 - }
381 -
382 -
383 -
384 - echo'
385 - <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.'>
386 - <source
387 - src="'.$hls_playback_url.'"
388 - type="application/x-mpegURL">
389 - </video>';
544 + }
390 545
391 - print '<script type="text/javascript">
392 - //<![CDATA[
393 - jQuery(document).ready(function(){
394 - wpstream_player_initialize("'.$now.'","'.$hls_playback_url.'","'.$live_conect_views.'","'.$autoplay.'");';
395 - print'});
396 - //]]>
397 - </script>';
398 - print '</div>';
399 -
400 -
401 - if(trim($hls_playback_url) ==''){
402 - // $show_wpstream_not_live_mess='';
403 - }else{
404 - print '<script type="text/javascript">
405 - //<![CDATA[
406 - jQuery(document).ready(function(){
407 - var player_wrapper = jQuery(".wpstream_live_player_wrapper");
408 - wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'");
409 - });
410 - //]]>
411 - </script>';
412 - }
413 -
414 -
415 - if($use_chat=="yes"){
416 - $this->wpstream_connect_to_chat($channel_id);
417 - }
418 -
419 - usleep (10000);
420 546
421 - }
422 547
423 548
424 549
425 550 /**
@@ -437,9 +562,10 @@
437 562 $thumb_id = get_post_thumbnail_id($channel_id);
438 563 $thumb = wp_get_attachment_image_src($thumb_id,'small');
439 564
440 565 $event_settings = $this->wpestream_return_event_settings($channel_id);
441 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id);
566 + $notes = 'wpstream_live_event_player_low_latency_note';
567 + $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
442 568 $hls_playback_url = '';
443 569 $live_conect_views = '';
444 570 $now = time().rand(0,10);
445 571
@@ -477,10 +603,10 @@
477 603 if(trim($hls_playback_url) ==''){
478 604 $show_wpstream_not_live_mess='';
479 605 }
480 606
481 -
482 - print '<div class="wpstream_not_live_mess " '.$show_wpstream_not_live_mess.' ><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'.esc_html__('We are not live at this moment. Please check back later.','wpstream').'</div></div>';
607 + $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ;
608 + 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>';
483 609
484 610
485 611 $poster_data=' poster="'.$thumb[0].'" ';
486 612 if($poster_show=='no'){
@@ -495,9 +621,9 @@
495 621
496 622
497 623 $autoplay='autoplay';
498 624 if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
499 - $autoplay='no_autoplay';
625 + $autoplay='';
500 626 }
501 627
502 628 echo'
503 629 <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
@@ -569,23 +695,19 @@
569 695 if(is_ssl()){
570 696 $domain_scheme='https';
571 697 }
572 698
573 - $corsorigin='';
574 - if( isset($local_event_options['vod_domain_lock']) ){
575 - if (intval( $local_event_options['vod_domain_lock']) ==0 ){
576 - $corsorigin='*';
577 - }
578 - }else{
579 - $corsorigin='*';
699 +
700 + $wpstream_vod_domain_lock = intval( get_option('wpstream_vod_domain_lock','') ) ;
701 + $corsorigin='*';
702 + if($wpstream_vod_domain_lock !== 0 ){
703 + $corsorigin=$domain_scheme.'://'.$domain['host'];
580 704 }
581 705
582 - if($corsorigin!='*'){
583 - $corsorigin=$domain_scheme.'://'.$domain['host'];
584 - }
585 -
706 +
586 707 $is_encrypt="false";
587 - if( isset($local_event_options['vod_encrypt']) && intval( $local_event_options['vod_encrypt']) ==1 ){
708 + $wpstream_vod_encrypt = intval( get_option('wpstream_vod_encrypt','') ) ;
709 + if( intval( $wpstream_vod_encrypt ) ==1 ){
588 710 $is_encrypt="true";
589 711 }
590 712
591 713 $hlsKeysUrlPrefix = get_site_url().'?wpstream_voddrm=';
@@ -625,11 +747,28 @@
625 747 return $hls_to_return;
626 748
627 749 }
628 750
751 + function wpstream_get_player_theme() {
752 + $player_theme = get_option('wpstream_video_player_theme');
753 + $is_streamify_user = $this->wpstream_is_streamify_user();
754 + if ( !empty($player_theme) && !$is_streamify_user ) {
755 + $this->wpstream_enqueue_player_theme_style( $player_theme );
756 + return 'vjs-theme-' . $player_theme;
757 + }
758 +
759 + return '';
760 + }
761 +
762 + function wpstream_enqueue_player_theme_style( $player_theme ) {
763 + if ( $player_theme != 'default' ) {
764 + 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');
765 +
766 + }
767 + }
768 +
629 769
630 770
631 -
632 771 /**
633 772 * VODPlayer uri details
634 773 *
635 774 * @author cretu
@@ -643,11 +782,11 @@
643 782 * 2 - free video encrypted
644 783 * 3 - free video -not encrypted
645 784 */
646 785
647 -
786 + $post_type = get_post_type($product_id);
648 787 $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
649 - if( ( is_singular('wpstream_product_vod') && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
788 + if( ( $post_type =='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
650 789
651 790 /*
652 791 * IF vide is encrypted- readed from vod,streaner
653 792 *
@@ -661,9 +800,9 @@
661 800 }
662 801 $video_path_final = $this->wpstream_request_video_on_demand_hls_player($video_path,$product_id);
663 802
664 803
665 - }else if( is_singular('wpstream_product_vod') && $free_video_type==3 ){
804 + }else if( $post_type =='wpstream_product_vod' && $free_video_type==3 ){
666 805
667 806 /* Video is unecrypted - read from local or youtube / vimeo
668 807 */
669 808
@@ -668,24 +807,17 @@
668 807 */
669 808
670 809 $video_type = 'video/mp4';
671 810 $video_path_final=esc_html(get_post_meta($product_id, 'wpstream_free_video_external', true));
672 -
673 - if (strpos($video_path_final, 'www.youtube') !== false) {
674 - $wpstream_data_setup= ' data-setup=\'{ "techOrder": ["youtube"], "sources": [{ "type": "video/youtube", "src": "'.$video_path_final.'"}] }\' ';
675 - $video_path_final='';
676 - }
677 - if (strpos($video_path_final, 'vimeo.com') !== false) {
678 - $wpstream_data_setup= ' data-setup=\'{"techOrder": ["vimeo"], "sources": [{ "type": "video/vimeo", "src": "'.$video_path_final.'"}], "vimeo": { "color": "#fbc51b"} }\' ';
679 - $video_path_final='';
680 - }
681 -
811 + wp_enqueue_script('youtube.min');
682 812 }
683 813
684 - $return_array=array();
814 + $return_array = array();
685 815 $return_array['video_path_final'] = $video_path_final;
686 816 $return_array['wpstream_data_setup']= $wpstream_data_setup;
687 817 $return_array['video_type'] = $video_type;
818 + $return_array['free_video_type'] = $free_video_type;
819 + $return_array['post_type'] = $post_type ;
688 820 return $return_array;
689 821 }
690 822
691 823
@@ -696,56 +828,315 @@
696 828 * @author cretu
697 829 */
698 830
699 831 public function wpstream_video_on_demand_player($product_id){
700 -
701 - $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id);
702 - $video_path_final = $uri_details['video_path_final'];
703 - $wpstream_data_setup = $uri_details['wpstream_data_setup'];
704 - $video_type = $uri_details['video_type'];
705 -
706 - $thumb_id = get_post_thumbnail_id($product_id);
707 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
708 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
709 -
710 - $poster_thumb = '';
711 - if(isset($thumb[0])){
712 - $poster_thumb=$thumb[0];
713 - }
832 + wp_enqueue_script('video.min');
833 + wp_enqueue_script('wpstream-player');
714 834
715 - $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true);
716 - $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true);
717 -
835 + $player_theme = $this->wpstream_get_player_theme();
718 836
719 - $pack = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
720 -
721 -
722 - if(isset($pack['available_data_mb']) && $pack['available_data_mb']>0){
723 -
724 - if($video_path_final==''){
725 - print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>';
726 - }
727 -
728 - 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"
729 - poster="'.esc_url($poster_thumb).'" '.$wpstream_data_setup.'>
837 + $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id);
838 + $video_path_final = $uri_details['video_path_final'];
839 + $wpstream_data_setup = $uri_details['wpstream_data_setup'];
840 + $video_type = $uri_details['video_type'];
841 + $now = time().rand(0,1000000);
730 842
731 - <source src="'.trim($video_path_final).'" type="'.$video_type.'">
732 - <p class="vjs-no-js">
733 - To view this video please enable JavaScript, and consider upgrading to a web browser that
734 - <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
735 - </p>
736 - </video>';
843 + $overlay_video_div_id = "random_id_".$now;
844 + print '<div id="'.esc_attr($overlay_video_div_id).'" class="vjs-title-overlay wpstream-video-title-overlay">'.esc_html__('Playing:','wpstream').' '.get_the_title($product_id).'</div>';
845 +
846 + $thumb_id = get_post_thumbnail_id($product_id);
847 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
848 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
849 +
850 + $poster_thumb = '';
851 + if(isset($thumb[0])){
852 + $poster_thumb=$thumb[0];
853 + }
854 +
855 + $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true);
856 + $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true);
857 +
858 +
859 + $pack = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_video_on_demand_player');
860 +
861 +
862 +
863 + $trailer_attachment_id = intval (get_post_meta( $product_id, 'video_trailer', true ));
864 + $video_trailer = '';
865 + $video_trailer_type = '';
866 + if($trailer_attachment_id!=0) {
867 + $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
868 + $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
869 + if( isset ($attachment_metadata['mime_type']) ) {
870 + $video_trailer_type = $attachment_metadata['mime_type'];
871 + }
872 + }
873 +
874 + // override trailer setup here (for testing)
875 + // $trailer_attachment_id = 1;
876 + // $video_trailer = '/wp-content/uploads/2023/10/production-ID_4608975.mp4';
877 + // $video_trailer = '/wp-content/uploads/2023/10/ultrawide.mp4';
878 +
879 + // If the video is self hosted or external, we should let the user see it
880 + $video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
881 +
882 +
883 + if ( (isset($pack['available_data_mb']) && $pack['available_data_mb']>0) || $video_type === 3 ) {
884 +
885 + if($video_path_final==''){
886 + if( $uri_details['post_type']=='wpstream_product_vod' && $uri_details['free_video_type']==3 ){
737 887 }else{
738 - print esc_html_e('Insufficient resources to stream this title','wpstream');
888 + print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>';
739 889 }
740 890
891 + }
892 +
893 + // TODO (crerem) populate these from VOD settings
894 + $autoplay = false;
895 + $muted = false;
896 +
897 + $wpstream_vod_start_muted = intval ( get_option('wpstream_vod_start_muted','') );
898 + if($wpstream_vod_start_muted===1){
899 + $muted=true;
900 + }
901 + $wpstream_vod_autoplay = intval ( get_option('wpstream_vod_autoplay','') );
902 + if($wpstream_vod_autoplay===1){
903 + $autoplay=true;
904 + }
905 +
906 + $poster_data = 'poster="'.esc_url($poster_thumb).'"';
907 + $has_trailer_class='';
908 + if($trailer_attachment_id !=0){
909 + $poster_data=''; // cancel poster for theme
910 + $has_trailer_class='wpstream_theme_player_has_trailer';
911 + }
912 +
913 + $player_logo_position = get_option('wpstream_player_logo_position');
914 + $player_logo_position_class = '';
915 + if( $player_logo_position && $player_logo_position!='' ){
916 + $player_logo_position_class = 'logo-' . explode( '-', $player_logo_position )[0];
917 + }
918 +
919 + 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 . '" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" playsinline preload="auto"
920 + '. $poster_data.' '.$wpstream_data_setup.'>
921 + <p class="vjs-no-js">
922 + To view this video please enable JavaScript, and consider upgrading to a web browser that
923 + <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
924 + </p>
925 + </video>';
926 +
927 + if($trailer_attachment_id !=0){
928 + print '<div class="wpstream_theme_trailer_wrapper">';
929 + print '<div id="wpstream_video_on_demand_play_trailer_btn_' . $now . '" class="wpstream_video_on_demand_play_trailer">
930 + <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
931 + <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"/>
932 + </svg>
933 + '.esc_html__('Play Trailer','wpstream').'</div>';
934 +
935 + print '<div class="wpstream_video_on_demand_play_video_wrapper" id="wpstream_video_on_demand_play_video_btn_' . $now . '" >
936 + <div class="wpstream_video_on_demand_play_video">
937 + <svg width="29" height="30" viewBox="0 0 29 30" fill="none" xmlns="http://www.w3.org/2000/svg">
938 + <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"/>
939 + </svg>
940 + </div>
941 + '.esc_html__('Play Video','wpstream').'
942 + </div>';
943 +
944 +
945 +
946 + print '<div id="wpstream_video_on_demand_mute_trailer_btn_' . $now . '" class="wpstream_video_on_demand_mute_trailer">
947 +
948 + <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
949 + <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"/>
950 + </svg>
951 + </div>';
952 + print '<div id="wpstream_video_on_demand_unmute_trailer_btn_' . $now . '" class="wpstream_video_on_demand_unmute_trailer">
953 + <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
954 + <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"/>
955 + </svg>
956 +
957 + </div>';
958 + print '<script type="text/javascript">
959 + //<![CDATA[
960 + jQuery(document).ready(function(){
961 + console.log("wpstream_video_on_demand_player 886");
962 + wpstream_player_initialize_vod({
963 + titleOverlayElementId:"'.$overlay_video_div_id.'",
964 + videoElementId: "wpstream-video-vod-'.$now.'",
965 + trailerUrl: "'.$video_trailer.'",
966 + videoUrl: "'.$video_path_final.'",
967 + autoplay: '.var_export($autoplay, true).',
968 + muted: '.var_export($muted, true).',
969 + playTrailerButtonElementId: "wpstream_video_on_demand_play_trailer_btn_'.$now.'",
970 + muteTrailerButtonElementId: "wpstream_video_on_demand_mute_trailer_btn_'.$now.'",
971 + unmuteTrailerButtonElementId: "wpstream_video_on_demand_unmute_trailer_btn_'.$now.'",
972 + playVideoButtonElementId: "wpstream_video_on_demand_play_video_btn_'.$now.'",
973 + playerLogoSettings: {
974 + image: "'. $this->wpstream_get_video_player_logo() . '",
975 + position: "' . esc_html( get_option('wpstream_player_logo_position','top-right') ) . '",
976 + opacity: ' . ( intval ( esc_html( get_option('wpstream_player_logo_opacity','100') ) ) / 100 ) . ',
977 + width: 100,
978 + height: "auto",
979 + padding: 10,
980 + },
981 + });
982 + });
983 + //]]>
984 + </script>';
985 + print '</div>';
986 + }
987 + else {
988 + print '<script type="text/javascript">
989 + //<![CDATA[
990 + jQuery(document).ready(function(){
991 +
992 + console.log("wpstream_video_on_demand_player 907");
993 +
994 + wpstream_player_initialize_vod({
995 + titleOverlayElementId:"'.$overlay_video_div_id.'",
996 + videoElementId: "wpstream-video-vod-'.$now.'",
997 + videoUrl: "'.$video_path_final.'",
998 + autoplay: '.var_export($autoplay, true).',
999 + muted: '.var_export($muted, true).',
1000 + playerLogoSettings: {
1001 + image: "'. $this->wpstream_get_video_player_logo() . '",
1002 + position: "' . esc_html( get_option('wpstream_player_logo_position','top-right') ) . '",
1003 + opacity: ' . ( intval ( esc_html( get_option('wpstream_player_logo_opacity','100') ) ) / 100 ) . ',
1004 + width: 100,
1005 + height: "auto",
1006 + padding: 10,
1007 + }
1008 + });
1009 + });
1010 + //]]>
1011 + </script>';
1012 + }
1013 + }else{
1014 + print '<div class="wpstream_insuficent_res">'.esc_html__('Insufficient resources to stream this title','wpstream').'</div>';
1015 + }
1016 +
741 1017 }
742 1018
743 1019
744 1020
1021 + /**
1022 + * VODPlayer url - only trailer - used in theme
1023 + *
1024 + * @author cretu
1025 + */
1026 + public function wpstream_video_on_demand_player_only_trailer($product_id){
1027 + wp_enqueue_script('video.min');
1028 + wp_enqueue_script('wpstream-player');
1029 +
1030 +
1031 + $player_theme = $this->wpstream_get_player_theme();
1032 + $now = time().rand(0,1000000);
1033 + $overlay_video_div_id = "random_id_".$now;
1034 + print '<div id="'.esc_attr($overlay_video_div_id).'" class="vjs-title-overlay wpstream-video-title-overlay">'.esc_html__('Playing:','wpstream').' '.get_the_title($product_id).'</div>';
1035 +
1036 +
1037 +
1038 + $thumb_id = get_post_thumbnail_id($product_id);
1039 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
1040 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
1041 +
1042 + $poster_thumb = '';
1043 + if(isset($thumb[0])){
1044 + $poster_thumb=$thumb[0];
1045 + }
1046 +
1047 +
1048 + $trailer_attachment_id = intval (get_post_meta( $product_id, 'video_trailer', true ));
1049 + $video_trailer = '';
1050 + $video_trailer_type = '';
1051 + if($trailer_attachment_id!=0) {
1052 + $video_trailer = wp_get_attachment_url( $trailer_attachment_id );
1053 + $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id);
1054 + if(isset($attachment_metadata['mime_type'])){
1055 + $video_trailer_type = $attachment_metadata['mime_type'];
1056 + }
1057 +
1058 + }
1059 +
1060 +
1061 + $autoplay = false;
1062 + $muted = false;
1063 +
1064 + if( intval ( get_option('wpstream_vod_start_muted','') ) === 1){
1065 + $muted = true;
1066 + }
1067 + if( intval ( get_option('wpstream_vod_autoplay','') ) === 1 ){
1068 + $autoplay = true;
1069 + }
1070 + $video_path_final='';
1071 + $has_trailer_class='wpstream_theme_player_has_trailer';
1072 +
1073 + 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.'" playsinline preload="auto"
1074 + >
1075 + <p class="vjs-no-js">
1076 + To view this video please enable JavaScript, and consider upgrading to a web browser that
1077 + <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a>
1078 + </p>
1079 + </video>';
1080 +
1081 + if($trailer_attachment_id !=0){
1082 + print '<div class="wpstream_theme_trailer_wrapper">';
1083 + print '<div id="wpstream_video_on_demand_play_trailer_btn_' . $now . '" class="wpstream_video_on_demand_play_trailer">
1084 + <svg width="30" height="24" viewBox="0 0 30 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1085 + <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"/>
1086 + </svg>
1087 + '.esc_html__('Play Trailer','wpstream').'
1088 + </div>';
1089 + print '<div id="wpstream_video_on_demand_mute_trailer_btn_' . $now . '" class="wpstream_video_on_demand_mute_trailer">
1090 + <svg width="37" height="36" viewBox="0 0 37 36" fill="none" xmlns="http://www.w3.org/2000/svg">
1091 + <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"/>
1092 + </svg>
1093 +
1094 +
1095 + </div>';
1096 + print '<div id="wpstream_video_on_demand_unmute_trailer_btn_' . $now . '" class="wpstream_video_on_demand_unmute_trailer">
1097 + <svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
1098 + <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"/>
1099 + </svg>
1100 +
1101 + </div>';
1102 + print '<script type="text/javascript">
1103 + //<![CDATA[
1104 + jQuery(document).ready(function(){
1105 +
1106 + console.log("wpstream_video_on_demand_player trailer 995");
1107 +
1108 + wpstream_player_initialize_vod({
1109 + titleOverlayElementId:"'.$overlay_video_div_id.'",
1110 + videoElementId: "wpstream-video-vod-'.$now.'",
1111 + trailerUrl: "'.$video_trailer.'",
1112 + autoplay: '.var_export($autoplay, true).',
1113 + muted: '.var_export($muted, true).',
1114 + playTrailerButtonElementId: "wpstream_video_on_demand_play_trailer_btn_'.$now.'",
1115 + muteTrailerButtonElementId: "wpstream_video_on_demand_mute_trailer_btn_'.$now.'",
1116 + unmuteTrailerButtonElementId: "wpstream_video_on_demand_unmute_trailer_btn_'.$now.'",
1117 + playerLogoSettings: {
1118 + image: "'. $this->wpstream_get_video_player_logo() . '",
1119 + position: "' . esc_html( get_option('wpstream_player_logo_position','top-right') ) . '",
1120 + opacity: ' . ( intval ( esc_html( get_option('wpstream_player_logo_opacity','100') ) ) / 100 ) . ',
1121 + width: 100,
1122 + height: "auto",
1123 + padding: 10,
1124 + },
1125 + });
1126 + });
1127 + //]]>
1128 + </script>';
1129 + print '</div>';
1130 + }
1131 + else {
1132 + //just show the poster or don't show anything; no player needed
1133 + }
1134 +
1135 + }
1136 +
745 1137
746 1138
747 -
748 1139 /**
749 1140 *
750 1141 * edited 4.0
751 1142 *
@@ -757,25 +1148,101 @@
757 1148
758 1149 return get_option('wpstream_api_username_from_token');
759 1150 }
760 1151
761 - /**
762 - * check if the we can add display the player
763 - *
764 - * @since 3.12
765 - * returns html of the player
766 - */
1152 + /**
1153 + * check if the we can add display the player
1154 + *
1155 + * @since 3.12
1156 + * returns html of the player
1157 + */
767 1158
768 - public function wpstream_check_if_player_can_dsplay($product_id){
769 - if ( is_user_logged_in() ) {
1159 + public function wpstream_check_if_player_can_dsplay($product_id){
1160 + if ( is_user_logged_in() ) {
1161 +
1162 + $term_list = wp_get_post_terms($product_id, 'product_type');
1163 + $current_user = wp_get_current_user();
1164 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1165 +
1166 + $product = wc_get_product($product_id);
1167 + $product_type = $product->get_type();
1168 +
1169 +
1170 + if($subscription_model==1){ // if we have Neflix mode
1171 + if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
1172 + return false;
1173 + }
1174 + if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
1175 + return true;
1176 + }
1177 + }else{
1178 + // ppv mode
770 1179
771 - $term_list = wp_get_post_terms($product_id, 'product_type');
1180 + if( $product_type=='subscription' ){
1181 +
1182 +// $user_subscriptions = wcs_get_users_subscriptions($current_user->ID );
1183 +// foreach ($user_subscriptions as $subscription) {
1184 +// $subscription_status = $subscription->get_status();
1185 +// echo "</br>*** Subscription ID $subscription->ID for User ID $current_user->ID has status: $subscription_status";
1186 +// }
1187 +
1188 +
1189 + if( wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
1190 + // user has active subcription
1191 + return true;
1192 + }
1193 +
1194 + }else{
1195 + if( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id)){
1196 + return true;
1197 + }
1198 + }
1199 +
1200 +
1201 + }
1202 + return false;
1203 +
1204 + }
1205 + return false;
1206 +
1207 + }
1208 +
1209 +
1210 +
1211 + /**
1212 + * check if the we can add display the player - theme variant
1213 + *
1214 + * @since 3.12
1215 + * returns html of the player
1216 + */
1217 + public function wpstream_check_if_player_can_dsplay_theme($product_id){
1218 +
1219 + $post_type= get_post_type($product_id);
1220 +
1221 +
1222 +
1223 + if($post_type=='wpstream_product_vod' || $post_type=='wpstream_product'){
1224 + return true; // if we have free vod or live
1225 + }
1226 +
1227 +
1228 +
1229 + if ( is_user_logged_in() && $post_type==='product' ) {
1230 +
1231 + $product = wc_get_product( $product_id );
1232 + $product_type = $product->get_type();
1233 + $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle',true);
1234 +
1235 +
1236 +
1237 +
1238 +
772 1239 $current_user = wp_get_current_user();
773 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
774 -
1240 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1241 + // print 'subscription model '.$subscription_model.'</br>';
775 1242
776 1243 if($subscription_model==1){ // if we have Neflix mode
777 - if( $term_list[0]->name=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
1244 + if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
778 1245 return false;
779 1246 }
780 1247 if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
781 1248 return true;
@@ -781,13 +1248,20 @@
781 1248 return true;
782 1249 }
783 1250 }else{
784 1251 // ppv mode
785 - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ||
786 - ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){
787 - return true;
1252 + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ){
1253 + return true; //simple product bought
1254 + }else if (function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ){
1255 + return true; // subscription boght
1256 + }else if( get_post_type($product_id) =='product' &&
1257 + intval($possible_bundle )!=0 &&
1258 + wc_customer_bought_product( $current_user->user_email, $current_user->ID, $possible_bundle)
1259 + ){
1260 + return true; // part of a boght bundle
788 1261 }
789 1262 }
1263 + // print ' fac return false </br>';
790 1264 return false;
791 1265
792 1266 }
793 1267 return false;
@@ -794,15 +1268,14 @@
794 1268
795 1269 }
796 1270
797 1271
798 -
799 1272 /**
800 - * in plugin - check if global subscription model is enabled
801 - *
802 - * @since 3.12
1273 + * in plugin - check if global subscription model is enabled
1274 + *
1275 + * @since 3.12
803 1276 *
804 - */
1277 + */
805 1278 public function wpstream_in_plugin_check_global_subscription_model($product_id) {
806 1279
807 1280 // $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
808 1281 if( is_user_logged_in() && function_exists('wcs_user_has_subscription') ){
@@ -809,9 +1282,9 @@
809 1282
810 1283 global $woocommerce;
811 1284 $current_user = wp_get_current_user();
812 1285
813 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1286 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
814 1287 $main_subscription = intval( get_option('wpstream_global_sub_id',''));
815 1288
816 1289 if($subscription_model==1){
817 1290 $selected_sub= get_post_meta($product_id,'_wpstream_parent_sub',true) ;
@@ -854,11 +1327,11 @@
854 1327 *
855 1328 *
856 1329 *
857 1330 *
858 - * check if the user bought the product and display the player - TO REDo
859 - *
860 - * @since 3.0.1
1331 + * check if the user bought the product and display the player - TO REDo
1332 + *
1333 + * @since 3.0.1
861 1334 * returns html of the player
862 1335 *
863 1336 *
864 1337 *
@@ -863,17 +1336,22 @@
863 1336 *
864 1337 *
865 1338 *
866 1339 *
867 - */
1340 + */
868 1341 public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
1342 + if(function_exists('wpstream_remove_wpstream_filter')){
1343 + return;
1344 + }
869 1345 global $product;
870 1346 $product_id = $product->get_id();
871 1347 $current_user = wp_get_current_user();
1348 +
872 1349 if ( is_user_logged_in() ) {
873 -
1350 +
1351 +
874 1352 if($this->wpstream_check_if_player_can_dsplay($product_id) ){
875 -
1353 +
876 1354 echo '<div class="wpstream_player_wrapper "><div class="wpstream_player_container">';
877 1355
878 1356 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
879 1357 $term_list = wp_get_post_terms($product_id, 'product_type');
@@ -881,20 +1359,25 @@
881 1359
882 1360 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
883 1361 $this->wpstream_live_event_player($product_id);
884 1362 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
1363 +
885 1364 $this->wpstream_video_on_demand_player($product_id);
886 1365 }
887 1366 echo '</div></div>';
888 1367 }else{
889 -
1368 +
890 1369
891 1370 $term_list = wp_get_post_terms($product_id, 'product_type');
1371 +
892 1372 if( $term_list[0]->name=='subscription' ){
1373 +
893 1374 if( !wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
894 1375 $this->wpstream_display_no_buy_message('nobuy',$product_id);
895 1376 }
896 1377
1378 + }else{
1379 + $this->wpstream_display_no_buy_message('nobuy',$product_id);
897 1380 }
898 1381
899 1382
900 1383
@@ -913,13 +1396,13 @@
913 1396
914 1397 /**
915 1398 *
916 1399 *
917 - * check if the user bought the product and display the player - TO REDo
918 - *
919 - * @since 3.0.1
1400 + * check if the user bought the product and display the player - TO REDo
1401 + *
1402 + * @since 3.0.1
920 1403 * returns html of the player
921 - */
1404 + */
922 1405
923 1406 public function wpstream_chat_wrapper($product_id){
924 1407 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/templates/wpstream_chat_template.php';
925 1408 }
@@ -931,13 +1414,13 @@
931 1414
932 1415
933 1416
934 1417 /**
935 - * coonect to chat
936 - *
937 - * @since 1.12.2
1418 + * coonect to chat
1419 + *
1420 + * @since 1.12.2
938 1421 *
939 - */
1422 + */
940 1423
941 1424
942 1425
943 1426 public function wpstream_connect_to_chat($product_id){
@@ -986,15 +1469,15 @@
986 1469 }
987 1470
988 1471
989 1472 /**
990 - * display no buy Message
991 - *
992 - * @since 3.12.2
1473 + * display no buy Message
1474 + *
1475 + * @since 3.12.2
993 1476 *
994 - */
1477 + */
995 1478 public function wpstream_display_no_buy_message($log,$product_id) {
996 -
1479 +
997 1480 if($log=='sub_active'){
998 1481 $message= esc_html( get_option('wpstream_subscription_active','Your Subscription is Active.')) ;
999 1482 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1000 1483 echo '<div class="wpstream_notice"> '.$message.'</div>';
@@ -1005,9 +1488,9 @@
1005 1488 $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
1006 1489 }else{
1007 1490 $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
1008 1491 }
1009 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1492 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1010 1493 if($subscription_model==1){
1011 1494 $message =esc_html( get_option('wpstream_product_not_subscribe','You did not yet subscribe to this item.'));
1012 1495 }
1013 1496
@@ -1012,11 +1495,16 @@
1012 1495 }
1013 1496
1014 1497
1015 1498 if( get_post_type($product_id) == 'product' && $subscription_model==0 ){
1499 + $product = wc_get_product($product_id);
1500 + $term_list = wp_get_post_terms($product_id, 'product_type');
1501 + $product_type = $product->get_type();
1502 + $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
1503 +
1016 1504
1017 - $term_list = wp_get_post_terms($product_id, 'product_type');
1018 - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
1505 +
1506 + if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream' || $product_type=='subscription'){
1019 1507
1020 1508 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1021 1509 echo '<div class="wpstream_notice">'.$message.'</div>';
1022 1510 echo '</div></div>';
@@ -1023,11 +1511,14 @@
1023 1511
1024 1512 }
1025 1513
1026 1514 }else if( get_post_type($product_id) == 'product' && $subscription_model==1 ){
1027 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1028 - echo '<div class="wpstream_notice"> '.$message.'</div>';
1029 - echo '</div></div>';
1515 + $term_list = wp_get_post_terms($product_id, 'product_type');
1516 + if( $term_list[0]->name!=='simple'){
1517 + echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1518 + echo '<div class="wpstream_notice"> '.$message.'</div>';
1519 + echo '</div></div>';
1520 + }
1030 1521 }
1031 1522
1032 1523
1033 1524
@@ -1034,7 +1525,53 @@
1034 1525
1035 1526
1036 1527
1037 1528 }
1038 -
1039 -
1529 +
1530 + /**
1531 + * Get the video player logo URL.
1532 + *
1533 + * @return mixed|string
1534 + */
1535 + public function wpstream_get_video_player_logo() {
1536 + if ( $this->wpstream_is_streamify_user() ) {
1537 + return WPSTREAM_PLUGIN_DIR_URL . 'img/default_300.png';
1538 + }
1539 +
1540 + $logo = get_option( 'wpstream_player_logo', '' );
1541 + if ( ! empty( $logo ) ) {
1542 + return $logo;
1543 + }
1544 + }
1545 +
1546 + /**
1547 + * Get cached pack data or request fresh pack data
1548 + *
1549 + * @param bool $force_refresh Force a refresh of the cached data
1550 + * @return array Pack data
1551 + */
1552 + private function wpstream_get_cached_pack_data( $force_refresh = false ) {
1553 + $cached_data = get_transient( 'wpstream_user_pack_data' );
1554 +
1555 + if ( $force_refresh || $cached_data === false ) {
1556 + $fresh_data = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user('wpstream_get_cached_pack_data');
1557 + set_transient( 'wpstream_user_pack_data', $fresh_data, 60);
1558 +
1559 + return $fresh_data;
1560 + }
1561 +
1562 + return $cached_data;
1563 + }
1564 +
1565 + public function wpstream_is_streamify_user() {
1566 + return false;
1567 +// $pack_details = $this->wpstream_get_cached_pack_data();
1568 +//
1569 +// if ( isset( $pack_details['total_data'] ) && $pack_details['total_data'] === 500 &&
1570 +// isset( $pack_details['total_storage_mb'] ) && $pack_details['total_storage_mb'] === 100 &&
1571 +// isset( $pack_details['available_data'] ) && $pack_details['available_data'] <= 0
1572 +// ) {
1573 +// return true;
1574 +// }
1575 +// return false;
1576 + }
1040 1577 }