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