PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 3.7
WpStream – Live Streaming, Video on Demand, Pay Per View v3.7
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 +358 -517 4.53.7 View file →
@@ -22,9 +22,10 @@
22 22 add_action( 'wp_ajax_wpstream_player_check_status', array($this,'wpstream_player_check_status') );
23 23 add_action('wp_ajax_nopriv_wpstream_player_check_status', array($this,'wpstream_player_check_status'));
24 24
25 25
26 -
26 + add_action( 'wp_ajax_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient') );
27 + add_action('wp_ajax_nopriv_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient'));
27 28
28 29
29 30 }
30 31
@@ -29,15 +30,27 @@
29 30 }
30 31
31 32
32 33
33 -
34 + /**
35 + * clear status transients
36 + *
37 + * @author cretu
38 + */
34 39
40 +
41 + public function wpstream_force_clear_transient($event_id){
42 +
43 + $transient_name = 'event_data_to_return_'.$event_id;
44 + delete_transient($transient_name);
45 + update_post_meta($event_id,'statsUrl','');
46 + update_post_meta($event_id,'chatUrl','');
35 47
48 + }
49 +
50 +
51 +
36 52 /**
37 - *
38 - * edited 4.0
39 - *
40 53 * check player status
41 54 *
42 55 * @author cretu
43 56 */
@@ -42,54 +55,115 @@
42 55 * @author cretu
43 56 */
44 57
45 58 public function wpstream_player_check_status(){
46 - $channel_id = intval($_POST['channel_id']);
47 -
48 -
49 - $transient_name = 'event_data_to_return_'. $channel_id;
59 + $event_id = intval($_POST['event_id']);
60 + $show_id=$event_id;
61 + $transient_name = 'event_data_to_return_'.$event_id;
50 62 $event_data_for_transient = get_transient( $transient_name );
51 63
64 +
65 +
66 + if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
67 +
68 + $server_id = ''; // server id IS blank - need to retrive it
69 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
70 +
71 + if($server_id==''){
72 + update_post_meta($show_id,'server_id', '' );
73 +
74 + $server_id =$this->main->wpstream_live_connection->retrive_server_id_based_on_show_id($show_id);
75 +
76 + }
77 +
52 78
79 +
80 + update_post_meta($show_id,'server_id', $server_id );
81 + $values_array=array(
82 + "server_id" => esc_html($server_id),
83 + 'from_where' => 'wpstream_check_event_status_front_player'
84 + );
85 +
86 + if($server_id==''){
87 + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
88 + //print 'failed connection';
89 + return;
90 + }
91 +
92 +
93 +
94 + $url=WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/event_status/?access_token=".$token;
95 + $arguments = array(
96 + 'method' => 'GET',
97 + 'timeout' => 45,
98 + 'redirection' => 5,
99 + 'httpversion' => '1.0',
100 + 'blocking' => true,
101 + 'headers' => array(),
102 + 'body' => $values_array,
103 + 'cookies' => array()
104 + );
53 105
54 - if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
55 - $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);
57 - $event_data_for_transient = $event_status;
106 + $response = wp_remote_post($url,$arguments);
107 + $received_data = wp_remote_retrieve_body($response);
58 108
59 - set_transient($transient_name,$event_data_for_transient,45);
109 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
110 + $received_data_encoded=json_decode($received_data,true);
111 +
112 + if( isset($received_data_encoded['success']) && intval( $received_data_encoded['success'] ) ==1 ){
113 +
114 + /*
115 + * we set transient and return the array saved
116 + * false if no data
117 + *
118 + * */
119 + $event_data_for_transient= $this->main->wpstream_live_connection->api20_wpstream_update_event($received_data_encoded,$show_id,$server_id);
120 + }else{
121 + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
122 + }
123 +
124 + }else{
125 + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id);
126 + }
127 +
128 +
129 +
130 +
131 + if ( false === $event_data_for_transient || $event_data_for_transient=='' ){
132 + //we are not live
133 + $event_data_for_transient=array();
134 + $event_data_for_transient['hlsPlaybackUrl']='';
135 +
136 + }
60 137 }
61 138
62 139
63 - if( isset($event_data_for_transient['hls_playback_url']) && $event_data_for_transient['hls_playback_url']!=''){
140 +
141 + // 1==2 &&
142 +
143 + if( $event_data_for_transient['hlsPlaybackUrl']!=''){
64 144 echo json_encode( array(
65 145
66 146 'started' => 'yes',
67 - 'channel_id' => $channel_id,
68 - 'event_uri' => $event_data_for_transient['hls_playback_url'],
69 - 'live_conect_views' => $event_data_for_transient['stats_url'],
70 - 'chat_url' => $event_data_for_transient['chat_url'],
71 - '$event_data_for_transient'=>$event_data_for_transient
72 -
147 + 'server_id' => $event_data_for_transient['server_id'],
148 + 'event_id' => $event_id,
149 + 'event_uri' => $event_data_for_transient['hlsPlaybackUrl'],
150 + 'live_conect_views' => $event_data_for_transient['statsUrl'],
151 + 'chat_url' => $event_data_for_transient['chatUrl'],
73 152
74 153 ));
75 - update_post_meta($channel_id,'stream_name',$event_data_for_transient['stream_name']);
76 - update_post_meta($channel_id,'hls_key_retrieval_url',$event_data_for_transient['hls_key_retrieval_url']);
77 - delete_transient( 'free_event_streamName_'.$event_data_for_transient['stream_name']);
78 -
79 154 }else{
80 155 echo json_encode( array(
81 156 'started' => 'no',
82 - 'server_id' => '',
83 - 'channel_id' => $channel_id,
157 + 'server_id' => $server_id,
158 + 'event_id' => $event_id,
84 159 'event_uri' => '',
85 160 'live_conect_views' => '',
86 161 'chat_url' => '',
87 162
88 163 ));
89 -
164 + $this->wpstream_force_clear_transient($event_id);
90 165 }
91 -
92 166 die();
93 167 }
94 168
95 169
@@ -99,9 +173,9 @@
99 173 *
100 174 * @author cretu
101 175 */
102 176 public function wpstream_filter_the_title( $content ) {
103 - if( is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){
177 + if( is_singular('wpstream_product')){
104 178 global $post;
105 179 $args=array('id'=>$post->ID);
106 180 $custom_content = $this->wpstream_insert_player_inpage($args);
107 181 $content = '<div class="wpestream_inserted_player">'.$custom_content.'</div>'.$content;
@@ -153,32 +227,30 @@
153 227 */
154 228
155 229 public function wpstream_video_player_shortcode($from_sh_id='') {
156 230
157 -
158 -
159 231 if ( is_user_logged_in() ) {
160 232 global $product;
161 233 $current_user = wp_get_current_user();
162 234 $product_id = intval($from_sh_id);
163 - $term_list = wp_get_post_terms($product_id, 'product_type');
164 -
165 -
166 235
167 236
168 -
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' ){
237 + if ( ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) && wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ) || get_post_type($product_id)=='wpstream_product' ){
171 238 global $product;
172 239 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
173 240
174 241
175 242 if( get_post_type($product_id) == 'wpstream_product' ){
176 - $this->wpstream_live_event_player($product_id);
177 - }else if( get_post_type($product_id) == 'wpstream_product_vod' ){
178 - $this->wpstream_video_on_demand_player($product_id);
243 +
244 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
245 + if($wpstream_product_type==1){
246 + $this->wpstream_live_event_player($product_id);
247 + } else if($wpstream_product_type==2 || $wpstream_product_type==3){
248 + $this->wpstream_video_on_demand_player($product_id);
249 + }
250 +
179 251 }else{
180 -
252 + $term_list = wp_get_post_terms($product_id, 'product_type');
181 253 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
182 254
183 255 if( $term_list[0]->name=='live_stream' || ( $term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
184 256 $this->wpstream_live_event_player($product_id);
@@ -192,10 +264,9 @@
192 264 }else{
193 265
194 266 if( get_post_type($product_id) == 'product' ){
195 267 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
196 - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
197 - echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>';
268 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
198 269 echo '</div></div>';
199 270 }
200 271 }
201 272
@@ -202,22 +273,17 @@
202 273
203 274 }else{
204 275
205 276 $product_id = intval($from_sh_id);
206 - $term_list = wp_get_post_terms($product_id, 'product_type');
207 -
208 - if( get_post_type($product_id) == 'product' && ($term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand') ){
209 -
210 - echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
211 - $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
277 + if( get_post_type($product_id) == 'wpstream_product' ){
212 278
279 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
280 + if($wpstream_product_type==1){
281 + $this->wpstream_live_event_player($product_id);
282 + } else if($wpstream_product_type==2 || $wpstream_product_type==3){
283 + $this->wpstream_video_on_demand_player($product_id);
284 + }
213 285
214 - echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>';
215 - echo '</div></div>';
216 - }elseif( get_post_type($product_id) == 'wpstream_product' ){
217 - $this->wpstream_live_event_player($product_id);
218 - } else if( get_post_type($product_id) == 'wpstream_product_vod' ){
219 - $this->wpstream_video_on_demand_player($product_id);
220 286 }
221 287 }
222 288 }
223 289
@@ -242,9 +308,14 @@
242 308 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
243 309
244 310
245 311 if( get_post_type($product_id) == 'wpstream_product' ){
246 - $this->wpstream_live_event_player_low_latency($product_id);
312 +
313 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
314 + if($wpstream_product_type==1){
315 + $this->wpstream_live_event_player_low_latency($product_id);
316 + }
317 +
247 318 }else{
248 319 $term_list = wp_get_post_terms($product_id, 'product_type');
249 320 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
250 321
@@ -258,11 +329,9 @@
258 329 }else{
259 330
260 331 if( get_post_type($product_id) == 'product' ){
261 332 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
262 -
263 - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
264 - echo '<div class="wpstream_notice" style="background:#e16767;">'.$message.'</div>';
333 + echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html__('You did not buy this product!','wpstream').'</div>';
265 334 echo '</div></div>';
266 335 }
267 336 }
268 337
@@ -269,9 +338,13 @@
269 338
270 339 }else{
271 340 $product_id = intval($from_sh_id);
272 341 if( get_post_type($product_id) == 'wpstream_product' ){
273 - $this->wpstream_live_event_player_low_latency($product_id);
342 +
343 + $wpstream_product_type = esc_html(get_post_meta($product_id, 'wpstream_product_type', true));
344 + if($wpstream_product_type==1){
345 + $this->wpstream_live_event_player_low_latency($product_id);
346 + }
274 347 }
275 348 }
276 349 }
277 350
@@ -292,115 +365,54 @@
292 365 }
293 366 }
294 367 return $url;
295 368 }
296 -
297 - /**
298 - * Get event settings
299 - *
300 - * @author cretu
301 - */
302 369
303 - function wpestream_return_event_settings($product_id){
304 -
305 - $local_event_options = get_post_meta($product_id,'local_event_options',true);
306 - if(!is_array($local_event_options)){
307 - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
308 - }
309 -
310 - return $local_event_options;
311 - }
312 370
313 -
314 -
315 371 /**
316 - * edited in 4.0
317 - *
318 372 * Live Event Player
319 373 *
320 374 * @author cretu
321 375 */
322 376
323 - function wpstream_live_event_player($channel_id,$poster_show='',$use_chat=''){
324 -
325 - $now = time().rand(0,1000000);
326 - $thumb_id = get_post_thumbnail_id($channel_id);
327 - $thumb = wp_get_attachment_image_src($thumb_id,'small');
328 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
329 - $autoplay = 'autoplay';
377 + function wpstream_live_event_player($product_id,$poster_show='',$use_chat=''){
378 + $live_event_uri = get_post_meta($product_id,'live_event_uri',true);
379 + $api20_event_id = get_post_meta($product_id,'server_id',true);
330 380
331 - $event_settings = $this->wpestream_return_event_settings($channel_id);
332 - $notes = 'wpstream_live_event_player_note';
333 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
334 - $hls_playback_url = '';
335 - $live_conect_views = '';
336 -
337 - if(isset($event_status['status']) && $event_status['status']=='active'){
338 - //live event
339 - if(isset($event_status['hls_playback_url'])){
340 - $hls_playback_url = $event_status['hls_playback_url'];
341 -
342 - update_post_meta($channel_id,'stream_name',$event_status['stream_name']);
343 - update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']);
344 - delete_transient( 'free_event_streamName_'.$event_status['stream_name']);
381 + $thumb_id = get_post_thumbnail_id($product_id);
382 + $thumb = wp_get_attachment_image_src($thumb_id,'small');
345 383
346 - $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
347 - $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
348 - $live_conect_views = $this->remove_http($live_conect_views);
384 + $chatUrl= get_post_meta($product_id,'statsUrl',true);
349 385
350 - }
351 - if(isset($event_status['chat_url'])){
352 - $chat_url = $event_status['chat_url'];
353 - }
354 -
355 - }else{
356 - // event not live
357 - }
386 +
387 + $live_event_uri_final = $this->wpstream_request_hls_player_dynamic('',$product_id);// buleala lu Gabi
388 + $now = time().rand(0,10);
389 + $live_conect_array = explode('live.streamer.wpstream.net',$live_event_uri_final);
390 + $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
391 + $live_conect_views = $this->remove_http($live_conect_views);
392 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
358 393
394 + echo '<div class="wpstream_live_player_wrapper" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" id="wpstream_live_player_wrapper'.$now.'" > '
395 + . '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
396 +
397 + $show_wpstream_not_live_mess=' style="display:none;" ';
398 + if(trim($live_event_uri_final) ==''){
399 + $show_wpstream_not_live_mess='';
400 + }
359 401
360 -
361 -
362 -
363 -
364 -
365 - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
366 - $autoplay='no_autoplay';
367 - }
368 -
369 - 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.'" > ';
370 402
371 - if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){
372 - echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
373 - }
374 -
375 - $show_wpstream_not_live_mess=' style="display:none;" ';
376 - if(trim($hls_playback_url) ==''){
377 -
378 - $show_wpstream_not_live_mess='';
379 - }
380 -
381 - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment. Please check back later.')) ;
382 - 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>';
403 + 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>';
383 404
384 - $poster_data='';
385 - if(isset($thumb[0])){
405 +
386 406 $poster_data=' poster="'.$thumb[0].'" ';
387 - }
388 - if($poster_show=='no'){
389 - $poster_data='';
390 - }
391 -
392 - $is_muted='';
393 - if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
394 - $is_muted=' muted ';
395 - }
407 + if($poster_show=='no'){
408 + $poster_data='';
409 + }
396 410
397 -
398 -
399 411 echo'
400 - <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.'>
412 + <video id="wpstream-video'.$now.'" '.$poster_data.' class="video-js vjs-default-skin vjs-16-9" playsinline="true" controls>
401 413 <source
402 - src="'.$hls_playback_url.'"
414 + src="'.$live_event_uri_final.'"
403 415 type="application/x-mpegURL">
404 416 </video>';
405 417
406 418 print '<script type="text/javascript">
@@ -405,9 +417,9 @@
405 417
406 418 print '<script type="text/javascript">
407 419 //<![CDATA[
408 420 jQuery(document).ready(function(){
409 - wpstream_player_initialize("'.$now.'","'.$hls_playback_url.'","'.$live_conect_views.'","'.$autoplay.'");';
421 + wpstream_player_initialize("'.$now.'","'.$live_event_uri_final.'","'.$live_conect_views.'");';
410 422 print'});
411 423 //]]>
412 424 </script>';
413 425 print '</div>';
@@ -412,9 +424,9 @@
412 424 </script>';
413 425 print '</div>';
414 426
415 427
416 - if(trim($hls_playback_url) ==''){
428 + if(trim($live_event_uri_final) ==''){
417 429 // $show_wpstream_not_live_mess='';
418 430 }else{
419 431 print '<script type="text/javascript">
420 432 //<![CDATA[
@@ -419,9 +431,9 @@
419 431 print '<script type="text/javascript">
420 432 //<![CDATA[
421 433 jQuery(document).ready(function(){
422 434 var player_wrapper = jQuery(".wpstream_live_player_wrapper");
423 - wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'");
435 + wpstream_read_websocket_info("'.$product_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chatUrl.'", "'.$live_event_uri_final.'");
424 436 });
425 437 //]]>
426 438 </script>';
427 439 }
@@ -427,9 +439,9 @@
427 439 }
428 440
429 441
430 442 if($use_chat=="yes"){
431 - $this->wpstream_connect_to_chat($channel_id);
443 + $this->wpstream_connect_to_chat($product_id);
432 444 }
433 445
434 446 usleep (10000);
435 447
@@ -437,66 +449,44 @@
437 449
438 450
439 451
440 452 /**
441 - *
442 - * Edited in 4.0
443 - *
444 - *
445 453 * Live Event Player
446 454 *
447 455 * @author cretu
448 456 */
449 457
450 - function wpstream_live_event_player_low_latency($channel_id,$poster_show='',$use_chat=''){
451 - $usernamestream = esc_html ( get_option('wpstream_api_username','') );
452 - $thumb_id = get_post_thumbnail_id($channel_id);
458 + function wpstream_live_event_player_low_latency($product_id,$poster_show='',$use_chat=''){
459 + $live_event_uri = get_post_meta($product_id,'live_event_uri',true);
460 + $api20_event_id = get_post_meta($product_id,'server_id',true);
461 +
462 + $thumb_id = get_post_thumbnail_id($product_id);
453 463 $thumb = wp_get_attachment_image_src($thumb_id,'small');
464 +
465 + $chatUrl= get_post_meta($product_id,'statsUrl',true);
454 466
455 - $event_settings = $this->wpestream_return_event_settings($channel_id);
456 - $notes = 'wpstream_live_event_player_low_latency_note';
457 - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
458 - $hls_playback_url = '';
459 - $live_conect_views = '';
460 - $now = time().rand(0,10);
467 +
468 + //$live_event_uri_final = $this->wpstream_request_hls_player_dynamic('',$product_id);// buleala lu Gabi
461 469
462 470
463 -
464 - if(isset($event_status['status']) && $event_status['status']=='active'){
465 - //live event
466 - if(isset($event_status['sldp_playback_url'])){
467 - $hls_playback_url = $event_status['sldp_playback_url'];
468 -
469 - $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
470 - $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
471 - $live_conect_views = $this->remove_http($live_conect_views);
471 + $live_event_uri_final= get_post_meta($product_id,'sldpPlaybackUrl',true);
472 + $now = time().rand(0,10);
473 +
474 + $usernamestream = esc_html ( get_option('wpstream_api_username','') );
472 475
473 - }
474 - if(isset($event_status['chat_url'])){
475 - $chat_url =$event_status['chat_url'];
476 - }
477 -
478 - }else{
479 - // event not live
480 - }
481 476
477 +
482 478
483 -
484 -
485 - echo '<div class="wpstream_live_player_wrapper function_wpstream_live_event_player_low_latency wpstream_low_latency" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$channel_id.'" id="wpstream_live_player_wrapper'.$now.'" > ';
486 -
487 -
488 - if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){
489 - echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
490 - }
479 + echo '<div class="wpstream_live_player_wrapper wpstream_low_latency" data-now="'.$now.'" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" id="wpstream_live_player_wrapper'.$now.'" > '
480 + . '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
491 481
492 482 $show_wpstream_not_live_mess=' style="display:none;" ';
493 - if(trim($hls_playback_url) ==''){
483 + if(trim($live_event_uri_final) ==''){
494 484 $show_wpstream_not_live_mess='';
495 485 }
496 486
497 - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment. Please check back later.')) ;
498 - 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>';
487 +
488 + 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>';
499 489
500 490
501 491 $poster_data=' poster="'.$thumb[0].'" ';
502 492 if($poster_show=='no'){
@@ -502,22 +492,11 @@
502 492 if($poster_show=='no'){
503 493 $poster_data='';
504 494 }
505 495
506 -
507 - $is_muted='';
508 - if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
509 - $is_muted=' muted ';
510 - }
511 -
512 -
513 - $autoplay='autoplay';
514 - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
515 - $autoplay='no_autoplay';
516 - }
517 -
496 +
518 497 echo'
519 - <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
498 + <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' class="" >
520 499 </div>';
521 500
522 501 print '<script type="text/javascript">
523 502 //<![CDATA[
@@ -522,9 +501,9 @@
522 501 print '<script type="text/javascript">
523 502 //<![CDATA[
524 503 jQuery(document).ready(function(){
525 504 var low_latencyid="wpstream-video'.$now.'";
526 - document.addEventListener("DOMContentLoaded", initPlayer(low_latencyid, "'.$hls_playback_url.'","'.$is_muted.'","'.$autoplay.'" ) ); ';
505 + document.addEventListener("DOMContentLoaded", initPlayer(low_latencyid,"'.$live_event_uri_final.'") ); ';
527 506 print'});
528 507 //]]>
529 508 </script>';
530 509
@@ -529,9 +508,9 @@
529 508 </script>';
530 509
531 510
532 511
533 - if(trim($hls_playback_url) ==''){
512 + if(trim($live_event_uri_final) ==''){
534 513 // $show_wpstream_not_live_mess='';
535 514 }else{
536 515 print '<script type="text/javascript">
537 516 //<![CDATA[
@@ -536,9 +515,9 @@
536 515 print '<script type="text/javascript">
537 516 //<![CDATA[
538 517 jQuery(document).ready(function(){
539 518 var player_wrapper = jQuery(".wpstream_live_player_wrapper");
540 - wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'");
519 + wpstream_read_websocket_info("'.$product_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chatUrl.'", "'.$live_event_uri_final.'");
541 520 });
542 521 //]]>
543 522 </script>';
544 523 }
@@ -544,9 +523,9 @@
544 523 }
545 524
546 525
547 526 if($use_chat=="yes"){
548 - $this->wpstream_connect_to_chat($channel_id);
527 + $this->wpstream_connect_to_chat($product_id);
549 528 }
550 529
551 530 usleep (10000);
552 531
@@ -553,99 +532,128 @@
553 532 }
554 533
555 534
556 535
557 -
558 -
559 - /*
560 - *
561 - * Request HLS player
562 - *
563 - *
564 - *
536 + /**
537 + * HLS PLAYER
538 + *
539 + * @author cretu
565 540 */
566 - public function wpstream_request_video_on_demand_hls_player($video_name,$product_id){
567 - if($video_name==''){
568 - return '';
569 - }
570 -
571 - $transient_name = 'wpstream_video_on_demand_'.$video_name;
572 - $hls_to_return = get_transient( $transient_name );
573 - $hls_to_return = false;
541 + public function wpstream_request_hls_player_dynamic($server_id,$product_id){
542 +
543 + $transient_name = 'hls_to_return_'.$product_id;
544 + $hls_to_return = get_transient( $transient_name );
574 545
575 -
576 - if($hls_to_return==false){
577 -
578 - $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
579 - $url = 'video/info';
546 + if ( false === $hls_to_return || $hls_to_return=='' ) { //ws || $hls_to_return==''
547 +
548 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
549 + $values_array = array();
550 + $values_array['server_id'] = $server_id;
551 +
552 + if($server_id==''){
553 + $this->main->wpstream_live_connection->wpstream_check_event_status_front_player($product_id,$server_id);
554 + $server_id = get_post_meta($product_id,'server_id', true );
555 + $values_array['server_id'] = $server_id;
556 + }
580 557
581 - //corsorigin de check
582 - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
583 - $domain = parse_url ( get_site_url() );
584 - $domain_scheme = 'http';
585 - if(is_ssl()){
586 - $domain_scheme='https';
558 +
559 + if($server_id==''){
560 + delete_transient($transient_name);
561 + return '';exit();
587 562 }
563 +
564 + $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/ap20_get_player_hls_dynamic/?access_token=".$token;
588 565
589 - $corsorigin='';
590 - if( isset($local_event_options['vod_domain_lock']) ){
591 - if (intval( $local_event_options['vod_domain_lock']) ==0 ){
592 - $corsorigin='*';
593 - }
594 - }else{
595 - $corsorigin='*';
566 +
567 + $arguments = array(
568 + 'method' => 'GET',
569 + 'timeout' => 45,
570 + 'redirection' => 5,
571 + 'httpversion' => '1.0',
572 + 'blocking' => true,
573 + 'headers' => array(),
574 + 'body' => $values_array,
575 + 'cookies' => array()
576 + );
577 + $response = wp_remote_post($url,$arguments);
578 +
579 + $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
580 +
581 +
582 +
583 +
584 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
585 + $hls_to_return = trim($received_data);
586 +
587 +
588 + set_transient( $transient_name, $hls_to_return, 60 );
589 + return $hls_to_return;
590 + }else{
591 + return 'failed connection';
596 592 }
593 + exit();
594 + }else{
595 + return $hls_to_return;
596 + }
597 597
598 - if($corsorigin!='*'){
599 - $corsorigin=$domain_scheme.'://'.$domain['host'];
600 - }
598 + }
601 599
602 - $is_encrypt="false";
603 - if( isset($local_event_options['vod_encrypt']) && intval( $local_event_options['vod_encrypt']) ==1 ){
604 - $is_encrypt="true";
605 - }
606 600
607 - $hlsKeysUrlPrefix = get_site_url().'?wpstream_voddrm=';
608 - $encrypt = $is_encrypt;
609 - $debugDrm = false;
610 601
611 - $curl_post_fields=array(
612 - 'access_token' => $access_token,
613 - 'name' => $video_name,
614 - 'corsOrigin' => $corsorigin,
615 - 'encryptHls' => $encrypt,
616 - 'hlsKeysUrlPrefix' => $hlsKeysUrlPrefix,
617 - 'debugDrm' => $debugDrm,
602 + /**
603 + * HLS PLAYER
604 + *
605 + * @author cretu
606 + */
607 +
608 +
609 + public function wpstream_request_hls_player($product_id){
610 +
611 + $transient_name = 'hls_to_return_'.$product_id;
612 + $hls_to_return = get_transient( $transient_name );
613 +
614 + if ( false === $hls_to_return || $hls_to_return=='' ) {
615 +
616 + $show_id = intval($product_id);
617 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
618 + $values_array = array();
619 + $values_array['show_id'] = $show_id;
620 +
621 + $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/videos/ap20_get_player_hls/?access_token=".$token;
622 +
623 +
624 + $arguments = array(
625 + 'method' => 'GET',
626 + 'timeout' => 45,
627 + 'redirection' => 5,
628 + 'httpversion' => '1.0',
629 + 'blocking' => true,
630 + 'headers' => array(),
631 + 'body' => $values_array,
632 + 'cookies' => array()
618 633 );
634 + $response = wp_remote_post($url,$arguments);
635 +
636 + $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
619 637
620 -
621 - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
622 - $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
623 -
624 - if($curl_response_decoded['success']){
625 - set_transient( $transient_name, $curl_response_decoded['hlsUrl'] ,300);
626 - $hls_to_return = $curl_response_decoded['hlsUrl'];
627 - if( isset($curl_response_decoded['hlsDecryptionKey']) && isset($curl_response_decoded['hlsDecryptionKeyIndex']) ){
628 - update_post_meta($product_id,'hlsDecryptionKey',$curl_response_decoded['hlsDecryptionKey']);
629 - update_post_meta($product_id,'hlsDecryptionKeyIndex',$curl_response_decoded['hlsDecryptionKeyIndex']);
630 - }else{
631 - delete_post_meta($product_id,'hlsDecryptionKey');
632 - delete_post_meta($product_id,'hlsDecryptionKeyIndex');
633 - }
634 -
635 - }else{
636 - return '';
638 +
639 +
640 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
641 + $hls_to_return = trim($received_data);
642 + set_transient( $transient_name, $hls_to_return, 60 );
643 + return $hls_to_return = trim($received_data);
644 + }else{
645 + return 'failed connection';
637 646 }
638 -
647 + exit();
648 + }else{
649 + return $hls_to_return;
639 650 }
640 -
641 - return $hls_to_return;
642 -
651 +
643 652 }
644 653
645 -
646 -
647 -
654 +
655 +
648 656 /**
649 657 * VODPlayer uri details
650 658 *
651 659 * @author cretu
@@ -658,28 +666,38 @@
658 666 * 1 - free live channel
659 667 * 2 - free video encrypted
660 668 * 3 - free video -not encrypted
661 669 */
662 -
663 -
664 - $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
665 - if( ( get_post_type($product_id)=='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
670 + $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
671 +
672 +
673 + if($free_video_type==2 || get_post_type($product_id)=='product' ){
666 674
667 - /*
668 - * IF vide is encrypted- readed from vod,streaner
669 - *
670 - */
671 -
675 + /* IF vide is encrypted- readed from vod,streaner
676 + */
672 677
673 678 $video_type = 'application/x-mpegURL';
674 679 $video_path = get_post_meta($product_id,'_movie_url',true);
675 - if(get_post_type($product_id)=='wpstream_product_vod'){
680 + if(get_post_type($product_id)=='wpstream_product'){
676 681 $video_path = esc_html(get_post_meta($product_id, 'wpstream_free_video', true));
677 682 }
678 - $video_path_final = $this->wpstream_request_video_on_demand_hls_player($video_path,$product_id);
679 683
684 + $username = esc_html ( get_option('wpstream_api_username','') );
685 + if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
686 + $username = $this->wpstream_retrive_username();
687 + }
688 +
689 + if(strpos($username,'@')!=false){
690 + $username_array= explode('@', $username);
691 + $username=$username_array[0];
692 + }
693 +
694 + $video_path_final = 'https://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
695 + if(!is_ssl()){
696 + $video_path_final = 'http://vod.streamer.wpstream.net/'.$username.'/'.$video_path.'/index.m3u8?'.get_site_url();
697 + }
680 698
681 - }else if( get_post_type($product_id)=='wpstream_product_vod' && $free_video_type==3 ){
699 + }else if($free_video_type==3){
682 700
683 701 /* Video is unecrypted - read from local or youtube / vimeo
684 702 */
685 703
@@ -722,28 +740,13 @@
722 740 $thumb_id = get_post_thumbnail_id($product_id);
723 741 $thumb = wp_get_attachment_image_src($thumb_id,'small');
724 742 $usernamestream = esc_html ( get_option('wpstream_api_username','') );
725 743
726 - $poster_thumb = '';
727 - if(isset($thumb[0])){
728 - $poster_thumb=$thumb[0];
729 - }
730 -
731 - $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true);
732 - $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true);
733 -
734 -
735 744 $pack = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user();
736 -
737 -
738 - if(isset($pack['available_data_mb']) && $pack['available_data_mb']>0){
739 -
740 - if($video_path_final==''){
741 - print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>';
742 - }
743 -
744 - 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"
745 - poster="'.esc_url($poster_thumb).'" '.$wpstream_data_setup.'>
745 +
746 + if($pack['band']>0){
747 + echo '<video id="wpstream-video'.time().'" class="video-js vjs-default-skin vjs-16-9 kuk wpstream_video_on_demand" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" controls preload="auto"
748 + poster="'.$thumb[0].'" '.$wpstream_data_setup.'>
746 749
747 750 <source src="'.trim($video_path_final).'" type="'.$video_type.'">
748 751 <p class="vjs-no-js">
749 752 To view this video please enable JavaScript, and consider upgrading to a web browser that
@@ -761,137 +764,58 @@
761 764
762 765
763 766
764 767 /**
765 - *
766 - * edited 4.0
767 - *
768 768 * Retreive username for vod path
769 769 *
770 770 * @author cretu
771 771 */
772 772 private function wpstream_retrive_username(){
773 -
774 - return get_option('wpstream_api_username_from_token');
775 - }
776 -
777 - /**
778 - * check if the we can add display the player
779 - *
780 - * @since 3.12
781 - * returns html of the player
782 - */
783 -
784 - public function wpstream_check_if_player_can_dsplay($product_id){
785 - if ( is_user_logged_in() ) {
786 -
787 - $term_list = wp_get_post_terms($product_id, 'product_type');
788 - $current_user = wp_get_current_user();
789 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
790 -
791 -
792 - if($subscription_model==1){ // if we have Neflix mode
793 - if( $term_list[0]->name=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
794 - return false;
795 - }
796 - if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
797 - return true;
798 - }
799 - }else{
800 - // ppv mode
801 - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ||
802 - ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){
803 - return true;
804 - }
773 + $token = $this->main->wpstream_live_connection->wpstream_get_token();
774 +
775 + $url=WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/return_login/?access_token=".$token;
776 + $arguments = array(
777 + 'method' => 'GET',
778 + 'timeout' => 45,
779 + 'redirection' => 5,
780 + 'httpversion' => '1.0',
781 + 'blocking' => true,
782 + 'headers' => array(),
783 + 'cookies' => array()
784 + );
785 + $response = wp_remote_post($url,$arguments);
786 + $received_data = json_decode( wp_remote_retrieve_body($response) ,true);
787 + if( isset($response['response']['code']) && $response['response']['code']=='200'){
788 + return ($received_data); die();
789 + }else{
790 + print 'Failed to conbect media server';
791 + die();
805 792 }
806 - return false;
807 -
808 - }
809 - return false;
810 -
811 793 }
812 794
813 795
814 796
815 - /**
816 - * in plugin - check if global subscription model is enabled
817 - *
818 - * @since 3.12
819 - *
820 - */
821 - public function wpstream_in_plugin_check_global_subscription_model($product_id) {
822 797
823 - // $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
824 - if( is_user_logged_in() && function_exists('wcs_user_has_subscription') ){
825 -
826 - global $woocommerce;
827 - $current_user = wp_get_current_user();
828 798
829 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
830 - $main_subscription = intval( get_option('wpstream_global_sub_id',''));
831 -
832 - if($subscription_model==1){
833 - $selected_sub= get_post_meta($product_id,'_wpstream_parent_sub',true) ;
834 -
835 - if( is_array($selected_sub) ){
836 -
837 - // we have per product sub
838 - foreach($selected_sub as $key=>$subscrition_id ):
839 - if( wcs_user_has_subscription( $current_user->ID, $subscrition_id ,'active') ) {
840 - return true;
841 - }
842 - endforeach;
843 -
844 - } else if($main_subscription!=0){
845 -
846 - // if we have one main subscription
847 - if( wcs_user_has_subscription( $current_user->ID, $main_subscription ,'active') ) {
848 - return true;
849 - }
850 - }
851 -
852 -
853 - }
854 - return false;
855 -
856 - }
857 - // there is no woo subscription or user not logged in
858 - return false;
859 - }
860 -
861 -
862 -
863 -
864 -
865 -
866 -
867 -
868 -
869 799 /**
870 - *
871 - *
872 - *
873 - *
874 800 * check if the user bought the product and display the player - TO REDo
875 801 *
876 802 * @since 3.0.1
877 803 * returns html of the player
878 - *
879 - *
880 - *
881 - *
882 - *
883 804 */
884 - public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
885 - global $product;
886 - $product_id = $product->get_id();
887 - $current_user = wp_get_current_user();
805 + public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
806 +
888 807 if ( is_user_logged_in() ) {
889 -
890 - if($this->wpstream_check_if_player_can_dsplay($product_id) ){
891 -
892 - echo '<div class="wpstream_player_wrapper "><div class="wpstream_player_container">';
808 + global $product;
809 + $current_user = wp_get_current_user();
810 + $product_id = $product->get_id();
893 811
812 +
813 + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) || ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){
814 +
815 +
816 + echo '<div class="wpstream_player_wrapper"><div class="wpstream_player_container">';
817 +
894 818 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
895 819 $term_list = wp_get_post_terms($product_id, 'product_type');
896 820
897 821
@@ -901,36 +825,20 @@
901 825 $this->wpstream_video_on_demand_player($product_id);
902 826 }
903 827 echo '</div></div>';
904 828 }else{
905 -
906 -
907 - $term_list = wp_get_post_terms($product_id, 'product_type');
908 - if( $term_list[0]->name=='subscription' ){
909 - if( !wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
910 - $this->wpstream_display_no_buy_message('nobuy',$product_id);
911 - }
912 -
829 + if( get_post_type($product_id) == 'wpstream_product' ){
830 + echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
831 + echo '<div class="wpstream_notice">'.__('You did not buy this product!','wpstream').'</div>';
832 + echo '</div></div>';
913 833 }
914 -
915 -
916 -
917 834 }
918 835
919 836
920 - }else{
921 -
922 - $this->wpstream_display_no_buy_message('nolog',$product_id);
923 837 }
924 838 }
925 839
926 -
927 -
928 -
929 -
930 - /**
931 - *
932 - *
840 + /**
933 841 * check if the user bought the product and display the player - TO REDo
934 842 *
935 843 * @since 3.0.1
936 844 * returns html of the player
@@ -941,23 +849,9 @@
941 849 }
942 850
943 851
944 852
945 -
946 -
947 -
948 -
949 -
950 - /**
951 - * coonect to chat
952 - *
953 - * @since 1.12.2
954 - *
955 - */
956 -
957 -
958 -
959 - public function wpstream_connect_to_chat($product_id){
853 + public function wpstream_connect_to_chat($product_id){
960 854 $current_user = wp_get_current_user();
961 855 $userID = $current_user->ID;
962 856 $user_login = $current_user->user_login;
963 857
@@ -962,9 +856,9 @@
962 856 $user_login = $current_user->user_login;
963 857
964 858 $key='';
965 859
966 - $chat_url = get_post_meta($product_id,'chat_url',true);
860 + $chatUrl = get_post_meta($product_id,'chatUrl',true);
967 861
968 862
969 863 wp_enqueue_script( 'sockjs-0.3.min' );
970 864 wp_enqueue_script( 'emojione.min.js' );
@@ -984,9 +878,9 @@
984 878
985 879
986 880 if(!is_user_logged_in()){
987 881 $user_login='';
988 - $chat_url='';
882 + $chatUrl='';
989 883 }
990 884
991 885
992 886 print '<script type="text/javascript">
@@ -999,58 +893,5 @@
999 893 //]]>
1000 894 </script>';
1001 895
1002 896 }
1003 -
1004 -
1005 - /**
1006 - * display no buy Message
1007 - *
1008 - * @since 3.12.2
1009 - *
1010 - */
1011 - public function wpstream_display_no_buy_message($log,$product_id) {
1012 -
1013 - if($log=='sub_active'){
1014 - $message= esc_html( get_option('wpstream_subscription_active','Your Subscription is Active.')) ;
1015 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1016 - echo '<div class="wpstream_notice"> '.$message.'</div>';
1017 - echo '</div></div>';
1018 - return;
1019 -
1020 - }else if($log=='nolog'){
1021 - $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
1022 - }else{
1023 - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
1024 - }
1025 - $subscription_model = esc_html( get_option('wpstream_global_sub','')) ;
1026 - if($subscription_model==1){
1027 - $message =esc_html( get_option('wpstream_product_not_subscribe','You did not yet subscribe to this item.'));
1028 - }
1029 -
1030 -
1031 - if( get_post_type($product_id) == 'product' && $subscription_model==0 ){
1032 -
1033 - $term_list = wp_get_post_terms($product_id, 'product_type');
1034 - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream'){
1035 -
1036 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1037 - echo '<div class="wpstream_notice">'.$message.'</div>';
1038 - echo '</div></div>';
1039 -
1040 - }
1041 -
1042 - }else if( get_post_type($product_id) == 'product' && $subscription_model==1 ){
1043 - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1044 - echo '<div class="wpstream_notice"> '.$message.'</div>';
1045 - echo '</div></div>';
1046 - }
1047 -
1048 -
1049 -
1050 -
1051 -
1052 -
1053 - }
1054 -
1055 -
1056 897 }