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 +768 -234 4.4.94.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,22 +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 -
51 + $usefull_info =' get cache from transiet';
54 52 if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
55 53 $notes = 'wpstream_player_check_status_note_from_js';
56 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
54 + $event_status = $this->main->wpstream_live_connection->wpstream_check_event_status_api_call($channel_id,$notes);
57 55 $event_data_for_transient = $event_status;
58 -
56 + $usefull_info =' no cache found';
59 57 set_transient($transient_name,$event_data_for_transient,45);
60 58 }
61 59
62 60
63 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();
64 64 echo json_encode( array(
65 65
66 66 'started' => 'yes',
67 + 'usefull_info' => $usefull_info,
67 68 'channel_id' => $channel_id,
68 69 'event_uri' => $event_data_for_transient['hls_playback_url'],
69 70 'live_conect_views' => $event_data_for_transient['stats_url'],
70 71 'chat_url' => $event_data_for_transient['chat_url'],
@@ -71,20 +72,25 @@
71 72 '$event_data_for_transient'=>$event_data_for_transient
72 73
73 74
74 75 ));
76 + $usedfull_info =' ';
75 77 update_post_meta($channel_id,'stream_name',$event_data_for_transient['stream_name']);
76 78 update_post_meta($channel_id,'hls_key_retrieval_url',$event_data_for_transient['hls_key_retrieval_url']);
77 79 delete_transient( 'free_event_streamName_'.$event_data_for_transient['stream_name']);
78 80
79 81 }else{
82 + // cleanup any previous echo before sending json
83 + ob_end_clean();
80 84 echo json_encode( array(
81 85 'started' => 'no',
86 + 'usefull_info' => $usefull_info,
82 87 'server_id' => '',
83 - 'channel_id' => $channel_id,
88 + 'channel_id' => $channel_id,
84 89 'event_uri' => '',
85 90 'live_conect_views' => '',
86 91 'chat_url' => '',
92 +
87 93
88 94 ));
89 95
90 96 }
@@ -99,8 +105,12 @@
99 105 *
100 106 * @author cretu
101 107 */
102 108 public function wpstream_filter_the_title( $content ) {
109 + if(function_exists('wpstream_remove_wpstream_filter')){
110 + return $content;
111 + }
112 +
103 113 if( is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){
104 114 global $post;
105 115 $args=array('id'=>$post->ID);
106 116 $custom_content = $this->wpstream_insert_player_inpage($args);
@@ -153,22 +163,27 @@
153 163 */
154 164
155 165 public function wpstream_video_player_shortcode($from_sh_id='') {
156 166
157 -
167 + wp_enqueue_script('video.min');
168 + wp_enqueue_script('wpstream-player');
158 169
159 170 if ( is_user_logged_in() ) {
160 171 global $product;
161 172 $current_user = wp_get_current_user();
162 173 $product_id = intval($from_sh_id);
163 - $term_list = wp_get_post_terms($product_id, 'product_type');
164 -
174 + $term_list = wp_get_post_terms($product_id, 'product_type');
175 + $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle', true);
165 176
166 177
167 178
168 179
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' ){
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' ){
171 186 global $product;
172 187 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
173 188
174 189
@@ -192,9 +207,10 @@
192 207 }else{
193 208
194 209 if( get_post_type($product_id) == 'product' ){
195 210 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
196 - 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>';
197 213 echo '</div></div>';
198 214 }
199 215 }
200 216
@@ -201,12 +217,26 @@
201 217
202 218 }else{
203 219
204 220 $product_id = intval($from_sh_id);
205 - if( get_post_type($product_id) == 'wpstream_product' ){
206 - $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>';
207 235 } else if( get_post_type($product_id) == 'wpstream_product_vod' ){
208 - $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>';
209 239 }
210 240 }
211 241 }
212 242
@@ -218,9 +248,12 @@
218 248 * @author cretu
219 249 */
220 250
221 251 public function wpstream_video_player_shortcode_low_latency($from_sh_id='') {
252 + wp_enqueue_script('video.min');
253 + wp_enqueue_script('wpstream-player');
222 254
255 +
223 256 if ( is_user_logged_in() ) {
224 257 global $product;
225 258 $current_user = wp_get_current_user();
226 259 $product_id = intval($from_sh_id);
@@ -247,9 +280,11 @@
247 280 }else{
248 281
249 282 if( get_post_type($product_id) == 'product' ){
250 283 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
251 - 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>';
252 287 echo '</div></div>';
253 288 }
254 289 }
255 290
@@ -288,10 +323,13 @@
288 323 */
289 324
290 325 function wpestream_return_event_settings($product_id){
291 326
292 - $local_event_options = get_post_meta($product_id,'local_event_options',true);
293 - 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 ) {
294 332 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
295 333 }
296 334
297 335 return $local_event_options;
@@ -307,121 +345,206 @@
307 345 * @author cretu
308 346 */
309 347
310 348 function wpstream_live_event_player($channel_id,$poster_show='',$use_chat=''){
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);
349 + wp_enqueue_script('video.min');
350 + wp_enqueue_script('wpstream-player');
351 +
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=='' ) {
319 370 $notes = 'wpstream_live_event_player_note';
320 371 $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
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']);
372 + set_transient($transient_name, $event_status, 45);
373 + }
332 374
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
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 +
344 391 }
345 -
346 -
347 -
348 -
349 -
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 + }
350 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 + }
351 431
352 - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
353 - $autoplay='no_autoplay';
432 +
433 + $poster_data='';
434 + if(isset($thumb[0])){
435 + $poster_data=' poster="'.$thumb[0].'" ';
354 436 }
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>';
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'];
360 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.'>
361 481
362 - $show_wpstream_not_live_mess=' style="display:none;" ';
363 - 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>
364 494
365 - $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>';
366 502 }
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>';
370 -
371 - $poster_data='';
372 - if(isset($thumb[0])){
373 - $poster_data=' poster="'.$thumb[0].'" ';
374 - }
375 - if($poster_show=='no'){
376 - $poster_data='';
377 - }
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);
378 543
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>';
544 + }
392 545
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 546
423 - }
424 547
425 548
426 549
427 550 /**
@@ -480,9 +603,9 @@
480 603 if(trim($hls_playback_url) ==''){
481 604 $show_wpstream_not_live_mess='';
482 605 }
483 606
484 - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment. Please check back later.')) ;
607 + $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ;
485 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>';
486 609
487 610
488 611 $poster_data=' poster="'.$thumb[0].'" ';
@@ -498,9 +621,9 @@
498 621
499 622
500 623 $autoplay='autoplay';
501 624 if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
502 - $autoplay='no_autoplay';
625 + $autoplay='';
503 626 }
504 627
505 628 echo'
506 629 <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
@@ -572,23 +695,19 @@
572 695 if(is_ssl()){
573 696 $domain_scheme='https';
574 697 }
575 698
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='*';
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'];
583 704 }
584 705
585 - if($corsorigin!='*'){
586 - $corsorigin=$domain_scheme.'://'.$domain['host'];
587 - }
588 -
706 +
589 707 $is_encrypt="false";
590 - 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 ){
591 710 $is_encrypt="true";
592 711 }
593 712
594 713 $hlsKeysUrlPrefix = get_site_url().'?wpstream_voddrm=';
@@ -628,11 +747,28 @@
628 747 return $hls_to_return;
629 748
630 749 }
631 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 +
632 769
633 770
634 -
635 771 /**
636 772 * VODPlayer uri details
637 773 *
638 774 * @author cretu
@@ -646,11 +782,11 @@
646 782 * 2 - free video encrypted
647 783 * 3 - free video -not encrypted
648 784 */
649 785
650 -
786 + $post_type = get_post_type($product_id);
651 787 $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' ){
788 + if( ( $post_type =='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
653 789
654 790 /*
655 791 * IF vide is encrypted- readed from vod,streaner
656 792 *
@@ -664,9 +800,9 @@
664 800 }
665 801 $video_path_final = $this->wpstream_request_video_on_demand_hls_player($video_path,$product_id);
666 802
667 803
668 - }else if( get_post_type($product_id)=='wpstream_product_vod' && $free_video_type==3 ){
804 + }else if( $post_type =='wpstream_product_vod' && $free_video_type==3 ){
669 805
670 806 /* Video is unecrypted - read from local or youtube / vimeo
671 807 */
672 808
@@ -671,24 +807,17 @@
671 807 */
672 808
673 809 $video_type = 'video/mp4';
674 810 $video_path_final=esc_html(get_post_meta($product_id, 'wpstream_free_video_external', true));
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 -
811 + wp_enqueue_script('youtube.min');
685 812 }
686 813
687 - $return_array=array();
814 + $return_array = array();
688 815 $return_array['video_path_final'] = $video_path_final;
689 816 $return_array['wpstream_data_setup']= $wpstream_data_setup;
690 817 $return_array['video_type'] = $video_type;
818 + $return_array['free_video_type'] = $free_video_type;
819 + $return_array['post_type'] = $post_type ;
691 820 return $return_array;
692 821 }
693 822
694 823
@@ -699,56 +828,315 @@
699 828 * @author cretu
700 829 */
701 830
702 831 public function wpstream_video_on_demand_player($product_id){
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 - }
832 + wp_enqueue_script('video.min');
833 + wp_enqueue_script('wpstream-player');
717 834
718 - $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true);
719 - $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true);
720 -
835 + $player_theme = $this->wpstream_get_player_theme();
721 836
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.'>
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);
733 842
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>';
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 ){
740 887 }else{
741 - 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>';
742 889 }
743 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 +
744 1017 }
745 1018
746 1019
747 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 +
748 1137
749 1138
750 -
751 1139 /**
752 1140 *
753 1141 * edited 4.0
754 1142 *
@@ -760,25 +1148,101 @@
760 1148
761 1149 return get_option('wpstream_api_username_from_token');
762 1150 }
763 1151
764 - /**
765 - * check if the we can add display the player
766 - *
767 - * @since 3.12
768 - * returns html of the player
769 - */
1152 + /**
1153 + * check if the we can add display the player
1154 + *
1155 + * @since 3.12
1156 + * returns html of the player
1157 + */
770 1158
771 - public function wpstream_check_if_player_can_dsplay($product_id){
772 - 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
773 1179
774 - $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 +
775 1239 $current_user = wp_get_current_user();
776 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
777 -
1240 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1241 + // print 'subscription model '.$subscription_model.'</br>';
778 1242
779 1243 if($subscription_model==1){ // if we have Neflix mode
780 - 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
781 1245 return false;
782 1246 }
783 1247 if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
784 1248 return true;
@@ -784,13 +1248,20 @@
784 1248 return true;
785 1249 }
786 1250 }else{
787 1251 // ppv mode
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;
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
791 1261 }
792 1262 }
1263 + // print ' fac return false </br>';
793 1264 return false;
794 1265
795 1266 }
796 1267 return false;
@@ -797,15 +1268,14 @@
797 1268
798 1269 }
799 1270
800 1271
801 -
802 1272 /**
803 - * in plugin - check if global subscription model is enabled
804 - *
805 - * @since 3.12
1273 + * in plugin - check if global subscription model is enabled
1274 + *
1275 + * @since 3.12
806 1276 *
807 - */
1277 + */
808 1278 public function wpstream_in_plugin_check_global_subscription_model($product_id) {
809 1279
810 1280 // $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
811 1281 if( is_user_logged_in() && function_exists('wcs_user_has_subscription') ){
@@ -812,9 +1282,9 @@
812 1282
813 1283 global $woocommerce;
814 1284 $current_user = wp_get_current_user();
815 1285
816 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1286 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
817 1287 $main_subscription = intval( get_option('wpstream_global_sub_id',''));
818 1288
819 1289 if($subscription_model==1){
820 1290 $selected_sub= get_post_meta($product_id,'_wpstream_parent_sub',true) ;
@@ -857,11 +1327,11 @@
857 1327 *
858 1328 *
859 1329 *
860 1330 *
861 - * check if the user bought the product and display the player - TO REDo
862 - *
863 - * @since 3.0.1
1331 + * check if the user bought the product and display the player - TO REDo
1332 + *
1333 + * @since 3.0.1
864 1334 * returns html of the player
865 1335 *
866 1336 *
867 1337 *
@@ -866,17 +1336,22 @@
866 1336 *
867 1337 *
868 1338 *
869 1339 *
870 - */
1340 + */
871 1341 public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
1342 + if(function_exists('wpstream_remove_wpstream_filter')){
1343 + return;
1344 + }
872 1345 global $product;
873 1346 $product_id = $product->get_id();
874 1347 $current_user = wp_get_current_user();
1348 +
875 1349 if ( is_user_logged_in() ) {
876 -
1350 +
1351 +
877 1352 if($this->wpstream_check_if_player_can_dsplay($product_id) ){
878 -
1353 +
879 1354 echo '<div class="wpstream_player_wrapper "><div class="wpstream_player_container">';
880 1355
881 1356 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
882 1357 $term_list = wp_get_post_terms($product_id, 'product_type');
@@ -884,20 +1359,25 @@
884 1359
885 1360 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
886 1361 $this->wpstream_live_event_player($product_id);
887 1362 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
1363 +
888 1364 $this->wpstream_video_on_demand_player($product_id);
889 1365 }
890 1366 echo '</div></div>';
891 1367 }else{
892 -
1368 +
893 1369
894 1370 $term_list = wp_get_post_terms($product_id, 'product_type');
1371 +
895 1372 if( $term_list[0]->name=='subscription' ){
1373 +
896 1374 if( !wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
897 1375 $this->wpstream_display_no_buy_message('nobuy',$product_id);
898 1376 }
899 1377
1378 + }else{
1379 + $this->wpstream_display_no_buy_message('nobuy',$product_id);
900 1380 }
901 1381
902 1382
903 1383
@@ -916,13 +1396,13 @@
916 1396
917 1397 /**
918 1398 *
919 1399 *
920 - * check if the user bought the product and display the player - TO REDo
921 - *
922 - * @since 3.0.1
1400 + * check if the user bought the product and display the player - TO REDo
1401 + *
1402 + * @since 3.0.1
923 1403 * returns html of the player
924 - */
1404 + */
925 1405
926 1406 public function wpstream_chat_wrapper($product_id){
927 1407 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/templates/wpstream_chat_template.php';
928 1408 }
@@ -934,13 +1414,13 @@
934 1414
935 1415
936 1416
937 1417 /**
938 - * coonect to chat
939 - *
940 - * @since 1.12.2
1418 + * coonect to chat
1419 + *
1420 + * @since 1.12.2
941 1421 *
942 - */
1422 + */
943 1423
944 1424
945 1425
946 1426 public function wpstream_connect_to_chat($product_id){
@@ -989,15 +1469,15 @@
989 1469 }
990 1470
991 1471
992 1472 /**
993 - * display no buy Message
994 - *
995 - * @since 3.12.2
1473 + * display no buy Message
1474 + *
1475 + * @since 3.12.2
996 1476 *
997 - */
1477 + */
998 1478 public function wpstream_display_no_buy_message($log,$product_id) {
999 -
1479 +
1000 1480 if($log=='sub_active'){
1001 1481 $message= esc_html( get_option('wpstream_subscription_active','Your Subscription is Active.')) ;
1002 1482 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1003 1483 echo '<div class="wpstream_notice"> '.$message.'</div>';
@@ -1008,9 +1488,9 @@
1008 1488 $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
1009 1489 }else{
1010 1490 $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
1011 1491 }
1012 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1492 + $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1013 1493 if($subscription_model==1){
1014 1494 $message =esc_html( get_option('wpstream_product_not_subscribe','You did not yet subscribe to this item.'));
1015 1495 }
1016 1496
@@ -1015,11 +1495,16 @@
1015 1495 }
1016 1496
1017 1497
1018 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 +
1019 1504
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'){
1505 +
1506 + if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream' || $product_type=='subscription'){
1022 1507
1023 1508 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1024 1509 echo '<div class="wpstream_notice">'.$message.'</div>';
1025 1510 echo '</div></div>';
@@ -1026,11 +1511,14 @@
1026 1511
1027 1512 }
1028 1513
1029 1514 }else if( get_post_type($product_id) == 'product' && $subscription_model==1 ){
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>';
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 + }
1033 1521 }
1034 1522
1035 1523
1036 1524
@@ -1037,7 +1525,53 @@
1037 1525
1038 1526
1039 1527
1040 1528 }
1041 -
1042 -
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 + }
1043 1577 }