PluginProbe
WpStream – Live Streaming, Video on Demand, Pay Per View / 4.8
WpStream – Live Streaming, Video on Demand, Pay Per View v4.8
4.14.1 4.14.0 4.13.2 4.13.1 4.13 4.12.5 4.12.4 4.12.3 4.12.2 4.12.1 4.12 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5 4.5.1 4.5.11 4.5.11.1 4.5.11.2 4.5.11.4 4.5.11.5 4.5.11.6 All 181 releases
wpstream / includes / class-wpstream-player.php

class-wpstream-player.php in WpStream – Live Streaming, Video on Demand, Pay Per View 4.8, at includes/class-wpstream-player.php

1,578 lines 75.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * To change this license header, choose License Headers in Project Properties.
5 * To change this template file, choose Tools | Templates
6 * and open the template in the editor.
7 */
8
9
10 /**
11 * Description of class-wpstream-player
12 *
13 * @author cretu
14 */
15 class Wpstream_Player{
16 public $main;
17
18 public function __construct($plugin_main) {
19 $this->main = $plugin_main;
20
21 add_filter( 'the_content',array($this, 'wpstream_filter_the_title') );
22 add_action( 'woocommerce_before_single_product', array($this,'wpstream_user_logged_in_product_already_bought') );
23
24 add_action( 'wp_ajax_wpstream_player_check_status', array($this,'wpstream_player_check_status') );
25 add_action('wp_ajax_nopriv_wpstream_player_check_status', array($this,'wpstream_player_check_status'));
26
27 }
28
29
30
31
32
33
34 /**
35 *
36 * edited 4.0
37 *
38 * check player status
39 *
40 * @author cretu
41 */
42
43 public function wpstream_player_check_status(){
44 $channel_id = intval($_POST['channel_id']);
45
46
47 $transient_name = 'event_data_to_return_'. $channel_id;
48 $event_data_for_transient = get_transient( $transient_name );
49
50
51 $usefull_info =' get cache from transiet';
52 if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return==''
53 $notes = 'wpstream_player_check_status_note_from_js';
54 $event_status = $this->main->wpstream_live_connection->wpstream_check_event_status_api_call($channel_id,$notes);
55 $event_data_for_transient = $event_status;
56 $usefull_info =' no cache found';
57 set_transient($transient_name,$event_data_for_transient,45);
58 }
59
60
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 echo json_encode( array(
65
66 'started' => 'yes',
67 'usefull_info' => $usefull_info,
68 'channel_id' => $channel_id,
69 'event_uri' => $event_data_for_transient['hls_playback_url'],
70 'live_conect_views' => $event_data_for_transient['stats_url'],
71 'chat_url' => $event_data_for_transient['chat_url'],
72 '$event_data_for_transient'=>$event_data_for_transient
73
74
75 ));
76 $usedfull_info =' ';
77 update_post_meta($channel_id,'stream_name',$event_data_for_transient['stream_name']);
78 update_post_meta($channel_id,'hls_key_retrieval_url',$event_data_for_transient['hls_key_retrieval_url']);
79 delete_transient( 'free_event_streamName_'.$event_data_for_transient['stream_name']);
80
81 }else{
82 // cleanup any previous echo before sending json
83 ob_end_clean();
84 echo json_encode( array(
85 'started' => 'no',
86 'usefull_info' => $usefull_info,
87 'server_id' => '',
88 'channel_id' => $channel_id,
89 'event_uri' => '',
90 'live_conect_views' => '',
91 'chat_url' => '',
92
93
94 ));
95
96 }
97
98 die();
99 }
100
101
102
103 /**
104 * Insert player in page
105 *
106 * @author cretu
107 */
108 public function wpstream_filter_the_title( $content ) {
109 if(function_exists('wpstream_remove_wpstream_filter')){
110 return $content;
111 }
112
113 if( is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){
114 global $post;
115 $args=array('id'=>$post->ID);
116 $custom_content = $this->wpstream_insert_player_inpage($args);
117 $content = '<div class="wpestream_inserted_player">'.$custom_content.'</div>'.$content;
118 return $content;
119 }else{
120 return $content;
121 }
122 }
123
124 /**
125 * Insert player in page
126 *
127 * @author cretu
128 */
129
130 public function wpstream_insert_player_inpage($attributes, $content = null){
131 $product_id = '';
132 $return_string = '';
133 $attributes = shortcode_atts(
134 array(
135 'id' => 0,
136 ), $attributes) ;
137
138
139 if ( isset($attributes['id']) ){
140 $product_id=$attributes['id'];
141 }
142
143 if(intval($product_id)==0){
144 $product_id= $this->wpstream_player_retrive_first_id();
145 }
146
147 ob_start();
148
149 $this->wpstream_video_player_shortcode($product_id);
150 $return_string= ob_get_contents();
151 ob_end_clean();
152
153 return $return_string;
154 }
155
156
157
158
159 /**
160 * Video Player shortcode
161 *
162 * @author cretu
163 */
164
165 public function wpstream_video_player_shortcode($from_sh_id='') {
166
167 wp_enqueue_script('video.min');
168 wp_enqueue_script('wpstream-player');
169
170 if ( is_user_logged_in() ) {
171 global $product;
172 $current_user = wp_get_current_user();
173 $product_id = intval($from_sh_id);
174 $term_list = wp_get_post_terms($product_id, 'product_type');
175 $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle', true);
176
177
178
179
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' ){
186 global $product;
187 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
188
189
190 if( get_post_type($product_id) == 'wpstream_product' ){
191 $this->wpstream_live_event_player($product_id);
192 }else if( get_post_type($product_id) == 'wpstream_product_vod' ){
193 $this->wpstream_video_on_demand_player($product_id);
194 }else{
195
196 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
197
198 if( $term_list[0]->name=='live_stream' || ( $term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
199 $this->wpstream_live_event_player($product_id);
200 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
201 $this->wpstream_video_on_demand_player($product_id);
202 }
203 }
204
205
206 echo '</div></div>';
207 }else{
208
209 if( get_post_type($product_id) == 'product' ){
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_bought','You did not yet purchase this item.')) ;
212 echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>';
213 echo '</div></div>';
214 }
215 }
216
217
218 }else{
219
220 $product_id = intval($from_sh_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>';
235 } else if( get_post_type($product_id) == 'wpstream_product_vod' ){
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>';
239 }
240 }
241 }
242
243
244
245 /**
246 * Video Player shortcode - low latency
247 *
248 * @author cretu
249 */
250
251 public function wpstream_video_player_shortcode_low_latency($from_sh_id='') {
252 wp_enqueue_script('video.min');
253 wp_enqueue_script('wpstream-player');
254
255
256 if ( is_user_logged_in() ) {
257 global $product;
258 $current_user = wp_get_current_user();
259 $product_id = intval($from_sh_id);
260
261
262 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' ){
263 global $product;
264 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">';
265
266
267 if( get_post_type($product_id) == 'wpstream_product' ){
268 $this->wpstream_live_event_player_low_latency($product_id);
269 }else{
270 $term_list = wp_get_post_terms($product_id, 'product_type');
271 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
272
273 if( $term_list[0]->name=='live_stream' || ( $term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
274 $this->wpstream_live_event_player_low_latency($product_id);
275 }
276 }
277
278
279 echo '</div></div>';
280 }else{
281
282 if( get_post_type($product_id) == 'product' ){
283 echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">';
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>';
287 echo '</div></div>';
288 }
289 }
290
291
292 }else{
293 $product_id = intval($from_sh_id);
294 if( get_post_type($product_id) == 'wpstream_product' ){
295 $this->wpstream_live_event_player_low_latency($product_id);
296 }
297 }
298 }
299
300
301
302
303
304 /**
305 * Live Event Player
306 *
307 * @author cretu
308 */
309 function remove_http($url) {
310 $disallowed = array('http://', 'https://');
311 foreach($disallowed as $d) {
312 if(strpos($url, $d) === 0) {
313 return str_replace($d, '', $url);
314 }
315 }
316 return $url;
317 }
318
319 /**
320 * Get event settings
321 *
322 * @author cretu
323 */
324
325 function wpestream_return_event_settings($product_id){
326
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 ) {
332 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
333 }
334
335 return $local_event_options;
336 }
337
338
339
340 /**
341 * edited in 4.0
342 *
343 * Live Event Player
344 *
345 * @author cretu
346 */
347
348 function wpstream_live_event_player($channel_id,$poster_show='',$use_chat=''){
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=='' ) {
370 $notes = 'wpstream_live_event_player_note';
371 $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
372 set_transient($transient_name, $event_status, 45);
373 }
374
375 $hls_playback_url = '';
376 $live_conect_views = '';
377
378 if(isset($event_status['status']) && $event_status['status']=='active'){
379 //live event
380 if(isset($event_status['hls_playback_url'])){
381 $hls_playback_url = $event_status['hls_playback_url'];
382
383 update_post_meta($channel_id,'stream_name',$event_status['stream_name']);
384 update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']);
385 delete_transient( 'free_event_streamName_'.$event_status['stream_name']);
386
387 $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
388 $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
389 $live_conect_views = $this->remove_http($live_conect_views);
390
391 }
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 }
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 }
431
432
433 $poster_data='';
434 if(isset($thumb[0])){
435 $poster_data=' poster="'.$thumb[0].'" ';
436 }
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'];
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.'>
481
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>
494
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>';
502 }
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);
543
544 }
545
546
547
548
549
550 /**
551 *
552 * Edited in 4.0
553 *
554 *
555 * Live Event Player
556 *
557 * @author cretu
558 */
559
560 function wpstream_live_event_player_low_latency($channel_id,$poster_show='',$use_chat=''){
561 $usernamestream = esc_html ( get_option('wpstream_api_username','') );
562 $thumb_id = get_post_thumbnail_id($channel_id);
563 $thumb = wp_get_attachment_image_src($thumb_id,'small');
564
565 $event_settings = $this->wpestream_return_event_settings($channel_id);
566 $notes = 'wpstream_live_event_player_low_latency_note';
567 $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes);
568 $hls_playback_url = '';
569 $live_conect_views = '';
570 $now = time().rand(0,10);
571
572
573
574 if(isset($event_status['status']) && $event_status['status']=='active'){
575 //live event
576 if(isset($event_status['sldp_playback_url'])){
577 $hls_playback_url = $event_status['sldp_playback_url'];
578
579 $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url);
580 $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net';
581 $live_conect_views = $this->remove_http($live_conect_views);
582
583 }
584 if(isset($event_status['chat_url'])){
585 $chat_url =$event_status['chat_url'];
586 }
587
588 }else{
589 // event not live
590 }
591
592
593
594
595 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.'" > ';
596
597
598 if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){
599 echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>';
600 }
601
602 $show_wpstream_not_live_mess=' style="display:none;" ';
603 if(trim($hls_playback_url) ==''){
604 $show_wpstream_not_live_mess='';
605 }
606
607 $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ;
608 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>';
609
610
611 $poster_data=' poster="'.$thumb[0].'" ';
612 if($poster_show=='no'){
613 $poster_data='';
614 }
615
616
617 $is_muted='';
618 if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){
619 $is_muted=' muted ';
620 }
621
622
623 $autoplay='autoplay';
624 if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){
625 $autoplay='';
626 }
627
628 echo'
629 <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" >
630 </div>';
631
632 print '<script type="text/javascript">
633 //<![CDATA[
634 jQuery(document).ready(function(){
635 var low_latencyid="wpstream-video'.$now.'";
636 document.addEventListener("DOMContentLoaded", initPlayer(low_latencyid, "'.$hls_playback_url.'","'.$is_muted.'","'.$autoplay.'" ) ); ';
637 print'});
638 //]]>
639 </script>';
640
641
642
643 if(trim($hls_playback_url) ==''){
644 // $show_wpstream_not_live_mess='';
645 }else{
646 print '<script type="text/javascript">
647 //<![CDATA[
648 jQuery(document).ready(function(){
649 var player_wrapper = jQuery(".wpstream_live_player_wrapper");
650 wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'");
651 });
652 //]]>
653 </script>';
654 }
655
656
657 if($use_chat=="yes"){
658 $this->wpstream_connect_to_chat($channel_id);
659 }
660
661 usleep (10000);
662
663 }
664
665
666
667
668
669 /*
670 *
671 * Request HLS player
672 *
673 *
674 *
675 */
676 public function wpstream_request_video_on_demand_hls_player($video_name,$product_id){
677 if($video_name==''){
678 return '';
679 }
680
681 $transient_name = 'wpstream_video_on_demand_'.$video_name;
682 $hls_to_return = get_transient( $transient_name );
683 $hls_to_return = false;
684
685
686 if($hls_to_return==false){
687
688 $access_token = $this->main->wpstream_live_connection->wpstream_get_token();
689 $url = 'video/info';
690
691 //corsorigin de check
692 $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ;
693 $domain = parse_url ( get_site_url() );
694 $domain_scheme = 'http';
695 if(is_ssl()){
696 $domain_scheme='https';
697 }
698
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'];
704 }
705
706
707 $is_encrypt="false";
708 $wpstream_vod_encrypt = intval( get_option('wpstream_vod_encrypt','') ) ;
709 if( intval( $wpstream_vod_encrypt ) ==1 ){
710 $is_encrypt="true";
711 }
712
713 $hlsKeysUrlPrefix = get_site_url().'?wpstream_voddrm=';
714 $encrypt = $is_encrypt;
715 $debugDrm = false;
716
717 $curl_post_fields=array(
718 'access_token' => $access_token,
719 'name' => $video_name,
720 'corsOrigin' => $corsorigin,
721 'encryptHls' => $encrypt,
722 'hlsKeysUrlPrefix' => $hlsKeysUrlPrefix,
723 'debugDrm' => $debugDrm,
724 );
725
726
727 $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields);
728 $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY);
729
730 if($curl_response_decoded['success']){
731 set_transient( $transient_name, $curl_response_decoded['hlsUrl'] ,300);
732 $hls_to_return = $curl_response_decoded['hlsUrl'];
733 if( isset($curl_response_decoded['hlsDecryptionKey']) && isset($curl_response_decoded['hlsDecryptionKeyIndex']) ){
734 update_post_meta($product_id,'hlsDecryptionKey',$curl_response_decoded['hlsDecryptionKey']);
735 update_post_meta($product_id,'hlsDecryptionKeyIndex',$curl_response_decoded['hlsDecryptionKeyIndex']);
736 }else{
737 delete_post_meta($product_id,'hlsDecryptionKey');
738 delete_post_meta($product_id,'hlsDecryptionKeyIndex');
739 }
740
741 }else{
742 return '';
743 }
744
745 }
746
747 return $hls_to_return;
748
749 }
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
769
770
771 /**
772 * VODPlayer uri details
773 *
774 * @author cretu
775 */
776 public function wpstream_video_on_demand_player_uri_request($product_id){
777
778 $wpstream_data_setup = ' data-setup="{}" ';
779
780 /* free_video_type
781 * 1 - free live channel
782 * 2 - free video encrypted
783 * 3 - free video -not encrypted
784 */
785
786 $post_type = get_post_type($product_id);
787 $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true));
788 if( ( $post_type =='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){
789
790 /*
791 * IF vide is encrypted- readed from vod,streaner
792 *
793 */
794
795
796 $video_type = 'application/x-mpegURL';
797 $video_path = get_post_meta($product_id,'_movie_url',true);
798 if(get_post_type($product_id)=='wpstream_product_vod'){
799 $video_path = esc_html(get_post_meta($product_id, 'wpstream_free_video', true));
800 }
801 $video_path_final = $this->wpstream_request_video_on_demand_hls_player($video_path,$product_id);
802
803
804 }else if( $post_type =='wpstream_product_vod' && $free_video_type==3 ){
805
806 /* Video is unecrypted - read from local or youtube / vimeo
807 */
808
809 $video_type = 'video/mp4';
810 $video_path_final=esc_html(get_post_meta($product_id, 'wpstream_free_video_external', true));
811 wp_enqueue_script('youtube.min');
812 }
813
814 $return_array = array();
815 $return_array['video_path_final'] = $video_path_final;
816 $return_array['wpstream_data_setup']= $wpstream_data_setup;
817 $return_array['video_type'] = $video_type;
818 $return_array['free_video_type'] = $free_video_type;
819 $return_array['post_type'] = $post_type ;
820 return $return_array;
821 }
822
823
824
825 /**
826 * VODPlayer url
827 *
828 * @author cretu
829 */
830
831 public function wpstream_video_on_demand_player($product_id){
832 wp_enqueue_script('video.min');
833 wp_enqueue_script('wpstream-player');
834
835 $player_theme = $this->wpstream_get_player_theme();
836
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);
842
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 ){
887 }else{
888 print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>';
889 }
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
1017 }
1018
1019
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
1137
1138
1139 /**
1140 *
1141 * edited 4.0
1142 *
1143 * Retreive username for vod path
1144 *
1145 * @author cretu
1146 */
1147 private function wpstream_retrive_username(){
1148
1149 return get_option('wpstream_api_username_from_token');
1150 }
1151
1152 /**
1153 * check if the we can add display the player
1154 *
1155 * @since 3.12
1156 * returns html of the player
1157 */
1158
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
1179
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
1239 $current_user = wp_get_current_user();
1240 $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1241 // print 'subscription model '.$subscription_model.'</br>';
1242
1243 if($subscription_model==1){ // if we have Neflix mode
1244 if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode
1245 return false;
1246 }
1247 if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){
1248 return true;
1249 }
1250 }else{
1251 // ppv mode
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
1261 }
1262 }
1263 // print ' fac return false </br>';
1264 return false;
1265
1266 }
1267 return false;
1268
1269 }
1270
1271
1272 /**
1273 * in plugin - check if global subscription model is enabled
1274 *
1275 * @since 3.12
1276 *
1277 */
1278 public function wpstream_in_plugin_check_global_subscription_model($product_id) {
1279
1280 // $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true);
1281 if( is_user_logged_in() && function_exists('wcs_user_has_subscription') ){
1282
1283 global $woocommerce;
1284 $current_user = wp_get_current_user();
1285
1286 $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1287 $main_subscription = intval( get_option('wpstream_global_sub_id',''));
1288
1289 if($subscription_model==1){
1290 $selected_sub= get_post_meta($product_id,'_wpstream_parent_sub',true) ;
1291
1292 if( is_array($selected_sub) ){
1293
1294 // we have per product sub
1295 foreach($selected_sub as $key=>$subscrition_id ):
1296 if( wcs_user_has_subscription( $current_user->ID, $subscrition_id ,'active') ) {
1297 return true;
1298 }
1299 endforeach;
1300
1301 } else if($main_subscription!=0){
1302
1303 // if we have one main subscription
1304 if( wcs_user_has_subscription( $current_user->ID, $main_subscription ,'active') ) {
1305 return true;
1306 }
1307 }
1308
1309
1310 }
1311 return false;
1312
1313 }
1314 // there is no woo subscription or user not logged in
1315 return false;
1316 }
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326 /**
1327 *
1328 *
1329 *
1330 *
1331 * check if the user bought the product and display the player - TO REDo
1332 *
1333 * @since 3.0.1
1334 * returns html of the player
1335 *
1336 *
1337 *
1338 *
1339 *
1340 */
1341 public function wpstream_user_logged_in_product_already_bought($from_sh_id='') {
1342 if(function_exists('wpstream_remove_wpstream_filter')){
1343 return;
1344 }
1345 global $product;
1346 $product_id = $product->get_id();
1347 $current_user = wp_get_current_user();
1348
1349 if ( is_user_logged_in() ) {
1350
1351
1352 if($this->wpstream_check_if_player_can_dsplay($product_id) ){
1353
1354 echo '<div class="wpstream_player_wrapper "><div class="wpstream_player_container">';
1355
1356 $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true));
1357 $term_list = wp_get_post_terms($product_id, 'product_type');
1358
1359
1360 if( $term_list[0]->name=='live_stream' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){
1361 $this->wpstream_live_event_player($product_id);
1362 }else if( $term_list[0]->name=='video_on_demand' || ($term_list[0]->name=='subscription' && $is_subscription_live_event=='no' ) ){
1363
1364 $this->wpstream_video_on_demand_player($product_id);
1365 }
1366 echo '</div></div>';
1367 }else{
1368
1369
1370 $term_list = wp_get_post_terms($product_id, 'product_type');
1371
1372 if( $term_list[0]->name=='subscription' ){
1373
1374 if( !wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) {
1375 $this->wpstream_display_no_buy_message('nobuy',$product_id);
1376 }
1377
1378 }else{
1379 $this->wpstream_display_no_buy_message('nobuy',$product_id);
1380 }
1381
1382
1383
1384 }
1385
1386
1387 }else{
1388
1389 $this->wpstream_display_no_buy_message('nolog',$product_id);
1390 }
1391 }
1392
1393
1394
1395
1396
1397 /**
1398 *
1399 *
1400 * check if the user bought the product and display the player - TO REDo
1401 *
1402 * @since 3.0.1
1403 * returns html of the player
1404 */
1405
1406 public function wpstream_chat_wrapper($product_id){
1407 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/templates/wpstream_chat_template.php';
1408 }
1409
1410
1411
1412
1413
1414
1415
1416
1417 /**
1418 * coonect to chat
1419 *
1420 * @since 1.12.2
1421 *
1422 */
1423
1424
1425
1426 public function wpstream_connect_to_chat($product_id){
1427 $current_user = wp_get_current_user();
1428 $userID = $current_user->ID;
1429 $user_login = $current_user->user_login;
1430
1431 $key='';
1432
1433 $chat_url = get_post_meta($product_id,'chat_url',true);
1434
1435
1436 wp_enqueue_script( 'sockjs-0.3.min' );
1437 wp_enqueue_script( 'emojione.min.js' );
1438 wp_enqueue_script( "jquery-effects-core");
1439 wp_enqueue_script( 'jquery.linkify.min.js');
1440 wp_enqueue_script( 'ripples.min.js');
1441 wp_enqueue_script( 'material.min.js');
1442 wp_enqueue_script( 'chat.js');
1443
1444
1445
1446 wp_enqueue_style( 'chat.css');
1447 wp_enqueue_style( 'ripples.css');
1448 wp_enqueue_style( 'emojione.min.css');
1449
1450
1451
1452
1453 if(!is_user_logged_in()){
1454 $user_login='';
1455 $chat_url='';
1456 }
1457
1458
1459 print '<script type="text/javascript">
1460 //<![CDATA[
1461 jQuery(document).ready(function(){
1462 username = "'.$user_login.'";
1463 key="'.$key.'";
1464
1465 });
1466 //]]>
1467 </script>';
1468
1469 }
1470
1471
1472 /**
1473 * display no buy Message
1474 *
1475 * @since 3.12.2
1476 *
1477 */
1478 public function wpstream_display_no_buy_message($log,$product_id) {
1479
1480 if($log=='sub_active'){
1481 $message= esc_html( get_option('wpstream_subscription_active','Your Subscription is Active.')) ;
1482 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1483 echo '<div class="wpstream_notice"> '.$message.'</div>';
1484 echo '</div></div>';
1485 return;
1486
1487 }else if($log=='nolog'){
1488 $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ;
1489 }else{
1490 $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ;
1491 }
1492 $subscription_model = intval( get_option('wpstream_global_sub','')) ;
1493 if($subscription_model==1){
1494 $message =esc_html( get_option('wpstream_product_not_subscribe','You did not yet subscribe to this item.'));
1495 }
1496
1497
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
1504
1505
1506 if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream' || $product_type=='subscription'){
1507
1508 echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">';
1509 echo '<div class="wpstream_notice">'.$message.'</div>';
1510 echo '</div></div>';
1511
1512 }
1513
1514 }else if( get_post_type($product_id) == 'product' && $subscription_model==1 ){
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 }
1521 }
1522
1523
1524
1525
1526
1527
1528 }
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 }
1577 }
1578