| @@ -22,9 +22,10 @@ | ||
| 22 | 22 | add_action( 'wp_ajax_wpstream_player_check_status', array($this,'wpstream_player_check_status') ); |
| 23 | 23 | add_action('wp_ajax_nopriv_wpstream_player_check_status', array($this,'wpstream_player_check_status')); |
| 24 | 24 | |
| 25 | 25 | |
| 26 | - | |
| 26 | + add_action( 'wp_ajax_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient') ); | |
| 27 | + add_action('wp_ajax_nopriv_wpstream_force_clear_transient', array($this,'wpstream_force_clear_transient')); | |
| 27 | 28 | |
| 28 | 29 | |
| 29 | 30 | } |
| 30 | 31 | |
| @@ -29,15 +30,27 @@ | ||
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | |
| 32 | 33 | |
| 33 | - | |
| 34 | + /** | |
| 35 | + * clear status transients | |
| 36 | + * | |
| 37 | + * @author cretu | |
| 38 | + */ | |
| 34 | 39 | |
| 40 | + | |
| 41 | + public function wpstream_force_clear_transient($event_id){ | |
| 42 | + | |
| 43 | + $transient_name = 'event_data_to_return_'.$event_id; | |
| 44 | + delete_transient($transient_name); | |
| 45 | + update_post_meta($event_id,'statsUrl',''); | |
| 46 | + update_post_meta($event_id,'chatUrl',''); | |
| 35 | 47 | |
| 48 | + } | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 36 | 52 | /** |
| 37 | - * | |
| 38 | - * edited 4.0 | |
| 39 | - * | |
| 40 | 53 | * check player status |
| 41 | 54 | * |
| 42 | 55 | * @author cretu |
| 43 | 56 | */ |
| @@ -42,54 +55,115 @@ | ||
| 42 | 55 | * @author cretu |
| 43 | 56 | */ |
| 44 | 57 | |
| 45 | 58 | public function wpstream_player_check_status(){ |
| 46 | - $channel_id = intval($_POST['channel_id']); | |
| 47 | - | |
| 48 | - | |
| 49 | - $transient_name = 'event_data_to_return_'. $channel_id; | |
| 59 | + $event_id = intval($_POST['event_id']); | |
| 60 | + $show_id=$event_id; | |
| 61 | + $transient_name = 'event_data_to_return_'.$event_id; | |
| 50 | 62 | $event_data_for_transient = get_transient( $transient_name ); |
| 51 | 63 | |
| 64 | + | |
| 65 | + | |
| 66 | + if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return=='' | |
| 67 | + | |
| 68 | + $server_id = ''; // server id IS blank - need to retrive it | |
| 69 | + $token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 70 | + | |
| 71 | + if($server_id==''){ | |
| 72 | + update_post_meta($show_id,'server_id', '' ); | |
| 73 | + | |
| 74 | + $server_id =$this->main->wpstream_live_connection->retrive_server_id_based_on_show_id($show_id); | |
| 75 | + | |
| 76 | + } | |
| 77 | + | |
| 52 | 78 | |
| 79 | + | |
| 80 | + update_post_meta($show_id,'server_id', $server_id ); | |
| 81 | + $values_array=array( | |
| 82 | + "server_id" => esc_html($server_id), | |
| 83 | + 'from_where' => 'wpstream_check_event_status_front_player' | |
| 84 | + ); | |
| 85 | + | |
| 86 | + if($server_id==''){ | |
| 87 | + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id); | |
| 88 | + //print 'failed connection'; | |
| 89 | + return; | |
| 90 | + } | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + $url=WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/event_status/?access_token=".$token; | |
| 95 | + $arguments = array( | |
| 96 | + 'method' => 'GET', | |
| 97 | + 'timeout' => 45, | |
| 98 | + 'redirection' => 5, | |
| 99 | + 'httpversion' => '1.0', | |
| 100 | + 'blocking' => true, | |
| 101 | + 'headers' => array(), | |
| 102 | + 'body' => $values_array, | |
| 103 | + 'cookies' => array() | |
| 104 | + ); | |
| 53 | 105 | |
| 54 | - if ( false === $event_data_for_transient || $event_data_for_transient=='' ) { //ws || $hls_to_return=='' | |
| 55 | - $notes = 'wpstream_player_check_status_note_from_js'; | |
| 56 | - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes); | |
| 57 | - $event_data_for_transient = $event_status; | |
| 106 | + $response = wp_remote_post($url,$arguments); | |
| 107 | + $received_data = wp_remote_retrieve_body($response); | |
| 58 | 108 | |
| 59 | - set_transient($transient_name,$event_data_for_transient,45); | |
| 109 | + if( isset($response['response']['code']) && $response['response']['code']=='200'){ | |
| 110 | + $received_data_encoded=json_decode($received_data,true); | |
| 111 | + | |
| 112 | + if( isset($received_data_encoded['success']) && intval( $received_data_encoded['success'] ) ==1 ){ | |
| 113 | + | |
| 114 | + /* | |
| 115 | + * we set transient and return the array saved | |
| 116 | + * false if no data | |
| 117 | + * | |
| 118 | + * */ | |
| 119 | + $event_data_for_transient= $this->main->wpstream_live_connection->api20_wpstream_update_event($received_data_encoded,$show_id,$server_id); | |
| 120 | + }else{ | |
| 121 | + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id); | |
| 122 | + } | |
| 123 | + | |
| 124 | + }else{ | |
| 125 | + $this->main->wpstream_live_connection->wpstream_reset_event_data($show_id); | |
| 126 | + } | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + if ( false === $event_data_for_transient || $event_data_for_transient=='' ){ | |
| 132 | + //we are not live | |
| 133 | + $event_data_for_transient=array(); | |
| 134 | + $event_data_for_transient['hlsPlaybackUrl']=''; | |
| 135 | + | |
| 136 | + } | |
| 60 | 137 | } |
| 61 | 138 | |
| 62 | 139 | |
| 63 | - if( isset($event_data_for_transient['hls_playback_url']) && $event_data_for_transient['hls_playback_url']!=''){ | |
| 140 | + | |
| 141 | + // 1==2 && | |
| 142 | + | |
| 143 | + if( $event_data_for_transient['hlsPlaybackUrl']!=''){ | |
| 64 | 144 | echo json_encode( array( |
| 65 | 145 | |
| 66 | 146 | 'started' => 'yes', |
| 67 | - 'channel_id' => $channel_id, | |
| 68 | - 'event_uri' => $event_data_for_transient['hls_playback_url'], | |
| 69 | - 'live_conect_views' => $event_data_for_transient['stats_url'], | |
| 70 | - 'chat_url' => $event_data_for_transient['chat_url'], | |
| 71 | - '$event_data_for_transient'=>$event_data_for_transient | |
| 72 | - | |
| 147 | + 'server_id' => $event_data_for_transient['server_id'], | |
| 148 | + 'event_id' => $event_id, | |
| 149 | + 'event_uri' => $event_data_for_transient['hlsPlaybackUrl'], | |
| 150 | + 'live_conect_views' => $event_data_for_transient['statsUrl'], | |
| 151 | + 'chat_url' => $event_data_for_transient['chatUrl'], | |
| 73 | 152 | |
| 74 | 153 | )); |
| 75 | - update_post_meta($channel_id,'stream_name',$event_data_for_transient['stream_name']); | |
| 76 | - update_post_meta($channel_id,'hls_key_retrieval_url',$event_data_for_transient['hls_key_retrieval_url']); | |
| 77 | - delete_transient( 'free_event_streamName_'.$event_data_for_transient['stream_name']); | |
| 78 | - | |
| 79 | 154 | }else{ |
| 80 | 155 | echo json_encode( array( |
| 81 | 156 | 'started' => 'no', |
| 82 | - 'server_id' => '', | |
| 83 | - 'channel_id' => $channel_id, | |
| 157 | + 'server_id' => $server_id, | |
| 158 | + 'event_id' => $event_id, | |
| 84 | 159 | 'event_uri' => '', |
| 85 | 160 | 'live_conect_views' => '', |
| 86 | 161 | 'chat_url' => '', |
| 87 | 162 | |
| 88 | 163 | )); |
| 89 | - | |
| 164 | + $this->wpstream_force_clear_transient($event_id); | |
| 90 | 165 | } |
| 91 | - | |
| 92 | 166 | die(); |
| 93 | 167 | } |
| 94 | 168 | |
| 95 | 169 | |
| @@ -99,13 +173,9 @@ | ||
| 99 | 173 | * |
| 100 | 174 | * @author cretu |
| 101 | 175 | */ |
| 102 | 176 | public function wpstream_filter_the_title( $content ) { |
| 103 | - if(function_exists('remove_wpstream_filter')){ | |
| 104 | - return $content; | |
| 105 | - } | |
| 106 | - | |
| 107 | - if( is_singular('wpstream_product') || is_singular('wpstream_product_vod') ){ | |
| 177 | + if( is_singular('wpstream_product')){ | |
| 108 | 178 | global $post; |
| 109 | 179 | $args=array('id'=>$post->ID); |
| 110 | 180 | $custom_content = $this->wpstream_insert_player_inpage($args); |
| 111 | 181 | $content = '<div class="wpestream_inserted_player">'.$custom_content.'</div>'.$content; |
| @@ -157,36 +227,30 @@ | ||
| 157 | 227 | */ |
| 158 | 228 | |
| 159 | 229 | public function wpstream_video_player_shortcode($from_sh_id='') { |
| 160 | 230 | |
| 161 | - | |
| 162 | - | |
| 163 | 231 | if ( is_user_logged_in() ) { |
| 164 | 232 | global $product; |
| 165 | 233 | $current_user = wp_get_current_user(); |
| 166 | 234 | $product_id = intval($from_sh_id); |
| 167 | - $term_list = wp_get_post_terms($product_id, 'product_type'); | |
| 168 | - $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle', true); | |
| 169 | - | |
| 170 | 235 | |
| 171 | 236 | |
| 172 | - | |
| 173 | - if ( | |
| 174 | - | |
| 175 | - ( 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) ) || | |
| 176 | - ( 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) ) || | |
| 177 | - get_post_type($product_id)=='wpstream_product' || | |
| 178 | - 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' ){ | |
| 179 | 238 | global $product; |
| 180 | 239 | echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">'; |
| 181 | 240 | |
| 182 | 241 | |
| 183 | 242 | if( get_post_type($product_id) == 'wpstream_product' ){ |
| 184 | - $this->wpstream_live_event_player($product_id); | |
| 185 | - }else if( get_post_type($product_id) == 'wpstream_product_vod' ){ | |
| 186 | - $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 | + | |
| 187 | 251 | }else{ |
| 188 | - | |
| 252 | + $term_list = wp_get_post_terms($product_id, 'product_type'); | |
| 189 | 253 | $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true)); |
| 190 | 254 | |
| 191 | 255 | if( $term_list[0]->name=='live_stream' || ( $term_list[0]->name=='subscription' && $is_subscription_live_event=='yes' ) ){ |
| 192 | 256 | $this->wpstream_live_event_player($product_id); |
| @@ -200,10 +264,9 @@ | ||
| 200 | 264 | }else{ |
| 201 | 265 | |
| 202 | 266 | if( get_post_type($product_id) == 'product' ){ |
| 203 | 267 | echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">'; |
| 204 | - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ; | |
| 205 | - 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>'; | |
| 206 | 269 | echo '</div></div>'; |
| 207 | 270 | } |
| 208 | 271 | } |
| 209 | 272 | |
| @@ -210,22 +273,17 @@ | ||
| 210 | 273 | |
| 211 | 274 | }else{ |
| 212 | 275 | |
| 213 | 276 | $product_id = intval($from_sh_id); |
| 214 | - $term_list = wp_get_post_terms($product_id, 'product_type'); | |
| 215 | - | |
| 216 | - if( get_post_type($product_id) == 'product' && ($term_list[0]->name=='live_stream' || $term_list[0]->name=='video_on_demand') ){ | |
| 217 | - | |
| 218 | - echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">'; | |
| 219 | - $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' ){ | |
| 220 | 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 | + } | |
| 221 | 285 | |
| 222 | - echo '<div class="wpstream_notice" style="background:#e16767;">'.esc_html($message).'</div>'; | |
| 223 | - echo '</div></div>'; | |
| 224 | - }elseif( get_post_type($product_id) == 'wpstream_product' ){ | |
| 225 | - $this->wpstream_live_event_player($product_id); | |
| 226 | - } else if( get_post_type($product_id) == 'wpstream_product_vod' ){ | |
| 227 | - $this->wpstream_video_on_demand_player($product_id); | |
| 228 | 286 | } |
| 229 | 287 | } |
| 230 | 288 | } |
| 231 | 289 | |
| @@ -250,9 +308,14 @@ | ||
| 250 | 308 | echo '<div class="wpstream_player_wrapper wpstream_player_shortcode"><div class="wpstream_player_container">'; |
| 251 | 309 | |
| 252 | 310 | |
| 253 | 311 | if( get_post_type($product_id) == 'wpstream_product' ){ |
| 254 | - $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 | + | |
| 255 | 318 | }else{ |
| 256 | 319 | $term_list = wp_get_post_terms($product_id, 'product_type'); |
| 257 | 320 | $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true)); |
| 258 | 321 | |
| @@ -266,11 +329,9 @@ | ||
| 266 | 329 | }else{ |
| 267 | 330 | |
| 268 | 331 | if( get_post_type($product_id) == 'product' ){ |
| 269 | 332 | echo '<div class="wpstream_player_wrapper wpstream_player_shortcode no_buy"><div class="wpstream_player_container">'; |
| 270 | - | |
| 271 | - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ; | |
| 272 | - 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>'; | |
| 273 | 334 | echo '</div></div>'; |
| 274 | 335 | } |
| 275 | 336 | } |
| 276 | 337 | |
| @@ -277,9 +338,13 @@ | ||
| 277 | 338 | |
| 278 | 339 | }else{ |
| 279 | 340 | $product_id = intval($from_sh_id); |
| 280 | 341 | if( get_post_type($product_id) == 'wpstream_product' ){ |
| 281 | - $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 | + } | |
| 282 | 347 | } |
| 283 | 348 | } |
| 284 | 349 | } |
| 285 | 350 | |
| @@ -300,144 +365,68 @@ | ||
| 300 | 365 | } |
| 301 | 366 | } |
| 302 | 367 | return $url; |
| 303 | 368 | } |
| 304 | - | |
| 305 | - /** | |
| 306 | - * Get event settings | |
| 307 | - * | |
| 308 | - * @author cretu | |
| 309 | - */ | |
| 310 | 369 | |
| 311 | - function wpestream_return_event_settings($product_id){ | |
| 312 | - | |
| 313 | - $local_event_options = get_post_meta($product_id,'local_event_options',true); | |
| 314 | - if(!is_array($local_event_options)){ | |
| 315 | - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ; | |
| 316 | - } | |
| 317 | - | |
| 318 | - return $local_event_options; | |
| 319 | - } | |
| 320 | 370 | |
| 321 | - | |
| 322 | - | |
| 323 | 371 | /** |
| 324 | - * edited in 4.0 | |
| 325 | - * | |
| 326 | 372 | * Live Event Player |
| 327 | 373 | * |
| 328 | 374 | * @author cretu |
| 329 | 375 | */ |
| 330 | 376 | |
| 331 | - function wpstream_live_event_player($channel_id,$poster_show='',$use_chat=''){ | |
| 332 | - | |
| 333 | - $now = time().rand(0,1000000); | |
| 334 | - $thumb_id = get_post_thumbnail_id($channel_id); | |
| 335 | - $thumb = wp_get_attachment_image_src($thumb_id,'small'); | |
| 336 | - $usernamestream = esc_html ( get_option('wpstream_api_username','') ); | |
| 337 | - $autoplay = true; | |
| 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); | |
| 338 | 380 | |
| 339 | - $event_settings = $this->wpestream_return_event_settings($channel_id); | |
| 340 | - $notes = 'wpstream_live_event_player_note'; | |
| 341 | - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes); | |
| 342 | - $hls_playback_url = ''; | |
| 343 | - $live_conect_views = ''; | |
| 344 | - | |
| 345 | - if(isset($event_status['status']) && $event_status['status']=='active'){ | |
| 346 | - //live event | |
| 347 | - if(isset($event_status['hls_playback_url'])){ | |
| 348 | - $hls_playback_url = $event_status['hls_playback_url']; | |
| 349 | - | |
| 350 | - update_post_meta($channel_id,'stream_name',$event_status['stream_name']); | |
| 351 | - update_post_meta($channel_id,'hls_key_retrieval_url',$event_status['hls_key_retrieval_url']); | |
| 352 | - delete_transient( 'free_event_streamName_'.$event_status['stream_name']); | |
| 381 | + $thumb_id = get_post_thumbnail_id($product_id); | |
| 382 | + $thumb = wp_get_attachment_image_src($thumb_id,'small'); | |
| 353 | 383 | |
| 354 | - $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url); | |
| 355 | - $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net'; | |
| 356 | - $live_conect_views = $this->remove_http($live_conect_views); | |
| 384 | + $chatUrl= get_post_meta($product_id,'statsUrl',true); | |
| 357 | 385 | |
| 358 | - } | |
| 359 | - if(isset($event_status['chat_url'])){ | |
| 360 | - $chat_url = $event_status['chat_url']; | |
| 361 | - } | |
| 362 | - | |
| 363 | - }else{ | |
| 364 | - // event not live | |
| 365 | - } | |
| 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','') ); | |
| 366 | 393 | |
| 367 | - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){ | |
| 368 | - $autoplay=false; | |
| 369 | - } | |
| 370 | - | |
| 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 | + } | |
| 371 | 401 | |
| 372 | - | |
| 373 | - 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.'" > '; | |
| 374 | 402 | |
| 375 | - if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){ | |
| 376 | - echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>'; | |
| 377 | - } | |
| 378 | - | |
| 379 | - $show_wpstream_not_live_mess=' style="display:none;" '; | |
| 380 | - if(trim($hls_playback_url) ==''){ | |
| 381 | - | |
| 382 | - $show_wpstream_not_live_mess=''; | |
| 383 | - } | |
| 384 | - | |
| 385 | - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ; | |
| 386 | - print '<div class="wpstream_not_live_mess" '.$show_wpstream_not_live_mess.'><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'.esc_html($message_show).'</div></div>'; | |
| 403 | + print '<div class="wpstream_not_live_mess " '.$show_wpstream_not_live_mess.' ><div class="wpstream_not_live_mess_back"></div><div class="wpstream_not_live_mess_mess">'.esc_html__('We are not live at this moment. Please check back later.','wpstream').'</div></div>'; | |
| 387 | 404 | |
| 388 | - $poster_data=''; | |
| 389 | - if(isset($thumb[0])){ | |
| 405 | + | |
| 390 | 406 | $poster_data=' poster="'.$thumb[0].'" '; |
| 391 | - } | |
| 392 | - if($poster_show=='no'){ | |
| 393 | - $poster_data=''; | |
| 394 | - } | |
| 395 | - | |
| 396 | - $is_muted=false; | |
| 397 | - if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){ | |
| 398 | - $is_muted=true; | |
| 399 | - } | |
| 400 | - // override $is_muted and $autoplay here - for testing | |
| 401 | - // $autoplay = true; | |
| 402 | - // $is_muted = false; | |
| 403 | - | |
| 404 | - $autoplay_str = $autoplay ? 'autoplay' : ''; | |
| 405 | - $is_muted_str = $is_muted ? 'muted' : ''; | |
| 407 | + if($poster_show=='no'){ | |
| 408 | + $poster_data=''; | |
| 409 | + } | |
| 406 | 410 | |
| 407 | - // TODO (crerem) - setup trailer url here based on meta etc | |
| 408 | - // override trailer url here - for testing | |
| 409 | - $video_trailer = ''; | |
| 410 | - // $video_trailer = '/wp-content/uploads/2023/10/production-ID_4608975.mp4'; | |
| 411 | - // $video_trailer = '/wp-content/uploads/2023/10/ultrawide.mp4'; | |
| 412 | - | |
| 413 | - if ($video_trailer){ | |
| 414 | - print '<div id="wpstream_live_video_play_trailer_btn_' . $now . '" style="display: none;" class="dummy">'.esc_html('Play Teaser').'</div>'; | |
| 415 | - } | |
| 416 | 411 | echo' |
| 417 | - <video id="wpstream-video'.$now.'" '.$poster_data.' class="video-js vjs-default-skin vjs-fluid vjs-wpstream" playsinline="true" '.$is_muted_str." ".$autoplay_str.'> | |
| 418 | - | |
| 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"> | |
| 419 | 416 | </video>'; |
| 420 | - | |
| 417 | + | |
| 421 | 418 | print '<script type="text/javascript"> |
| 422 | - //<![CDATA[ | |
| 423 | - jQuery(document).ready(function(){ | |
| 424 | - wpstream_player_initialize({ | |
| 425 | - videoElementId: "'.$now.'", | |
| 426 | - trailerUrl: "'.$video_trailer.'", | |
| 427 | - contentUrl: "'.$hls_playback_url.'", | |
| 428 | - statsUri: "'.$live_conect_views.'", | |
| 429 | - autoplay: '.var_export($autoplay, true).', | |
| 430 | - muted: '.var_export($is_muted, true).', | |
| 431 | - playTrailerButtonElementId: "wpstream_live_video_play_trailer_btn_'.$now.'", | |
| 432 | - }); | |
| 433 | - }); | |
| 434 | - //]]> | |
| 435 | - </script>'; | |
| 419 | + //<![CDATA[ | |
| 420 | + jQuery(document).ready(function(){ | |
| 421 | + wpstream_player_initialize("'.$now.'","'.$live_event_uri_final.'","'.$live_conect_views.'");'; | |
| 422 | + print'}); | |
| 423 | + //]]> | |
| 424 | + </script>'; | |
| 436 | 425 | print '</div>'; |
| 437 | 426 | |
| 438 | 427 | |
| 439 | - if(trim($hls_playback_url) ==''){ | |
| 428 | + if(trim($live_event_uri_final) ==''){ | |
| 440 | 429 | // $show_wpstream_not_live_mess=''; |
| 441 | 430 | }else{ |
| 442 | 431 | print '<script type="text/javascript"> |
| 443 | 432 | //<![CDATA[ |
| @@ -442,9 +431,9 @@ | ||
| 442 | 431 | print '<script type="text/javascript"> |
| 443 | 432 | //<![CDATA[ |
| 444 | 433 | jQuery(document).ready(function(){ |
| 445 | 434 | var player_wrapper = jQuery(".wpstream_live_player_wrapper"); |
| 446 | - wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'"); | |
| 435 | + wpstream_read_websocket_info("'.$product_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chatUrl.'", "'.$live_event_uri_final.'"); | |
| 447 | 436 | }); |
| 448 | 437 | //]]> |
| 449 | 438 | </script>'; |
| 450 | 439 | } |
| @@ -450,9 +439,9 @@ | ||
| 450 | 439 | } |
| 451 | 440 | |
| 452 | 441 | |
| 453 | 442 | if($use_chat=="yes"){ |
| 454 | - $this->wpstream_connect_to_chat($channel_id); | |
| 443 | + $this->wpstream_connect_to_chat($product_id); | |
| 455 | 444 | } |
| 456 | 445 | |
| 457 | 446 | usleep (10000); |
| 458 | 447 | |
| @@ -460,66 +449,44 @@ | ||
| 460 | 449 | |
| 461 | 450 | |
| 462 | 451 | |
| 463 | 452 | /** |
| 464 | - * | |
| 465 | - * Edited in 4.0 | |
| 466 | - * | |
| 467 | - * | |
| 468 | 453 | * Live Event Player |
| 469 | 454 | * |
| 470 | 455 | * @author cretu |
| 471 | 456 | */ |
| 472 | 457 | |
| 473 | - function wpstream_live_event_player_low_latency($channel_id,$poster_show='',$use_chat=''){ | |
| 474 | - $usernamestream = esc_html ( get_option('wpstream_api_username','') ); | |
| 475 | - $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); | |
| 476 | 463 | $thumb = wp_get_attachment_image_src($thumb_id,'small'); |
| 464 | + | |
| 465 | + $chatUrl= get_post_meta($product_id,'statsUrl',true); | |
| 477 | 466 | |
| 478 | - $event_settings = $this->wpestream_return_event_settings($channel_id); | |
| 479 | - $notes = 'wpstream_live_event_player_low_latency_note'; | |
| 480 | - $event_status = $this->main->wpstream_live_connection-> wpstream_check_event_status_api_call($channel_id,$notes); | |
| 481 | - $hls_playback_url = ''; | |
| 482 | - $live_conect_views = ''; | |
| 483 | - $now = time().rand(0,10); | |
| 467 | + | |
| 468 | + //$live_event_uri_final = $this->wpstream_request_hls_player_dynamic('',$product_id);// buleala lu Gabi | |
| 484 | 469 | |
| 485 | 470 | |
| 486 | - | |
| 487 | - if(isset($event_status['status']) && $event_status['status']=='active'){ | |
| 488 | - //live event | |
| 489 | - if(isset($event_status['sldp_playback_url'])){ | |
| 490 | - $hls_playback_url = $event_status['sldp_playback_url']; | |
| 491 | - | |
| 492 | - $live_conect_array = explode('live.streamer.wpstream.net',$hls_playback_url); | |
| 493 | - $live_conect_views = $live_conect_array[0].'live.streamer.wpstream.net'; | |
| 494 | - $live_conect_views = $this->remove_http($live_conect_views); | |
| 471 | + $live_event_uri_final= get_post_meta($product_id,'sldpPlaybackUrl',true); | |
| 472 | + $now = time().rand(0,10); | |
| 473 | + | |
| 474 | + $usernamestream = esc_html ( get_option('wpstream_api_username','') ); | |
| 495 | 475 | |
| 496 | - } | |
| 497 | - if(isset($event_status['chat_url'])){ | |
| 498 | - $chat_url =$event_status['chat_url']; | |
| 499 | - } | |
| 500 | - | |
| 501 | - }else{ | |
| 502 | - // event not live | |
| 503 | - } | |
| 504 | 476 | |
| 477 | + | |
| 505 | 478 | |
| 506 | - | |
| 507 | - | |
| 508 | - 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.'" > '; | |
| 509 | - | |
| 510 | - | |
| 511 | - if( ( isset($event_settings['view_count'] ) && intval($event_settings['view_count'])==1 ) || !isset($event_settings['view_count']) ){ | |
| 512 | - echo '<div id="wpestream_live_counting" class="wpestream_live_counting"></div>'; | |
| 513 | - } | |
| 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>'; | |
| 514 | 481 | |
| 515 | 482 | $show_wpstream_not_live_mess=' style="display:none;" '; |
| 516 | - if(trim($hls_playback_url) ==''){ | |
| 483 | + if(trim($live_event_uri_final) ==''){ | |
| 517 | 484 | $show_wpstream_not_live_mess=''; |
| 518 | 485 | } |
| 519 | 486 | |
| 520 | - $message_show= esc_html( get_option('wpstream_you_are_not_live','We are not live at this moment')) ; | |
| 521 | - 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>'; | |
| 522 | 489 | |
| 523 | 490 | |
| 524 | 491 | $poster_data=' poster="'.$thumb[0].'" '; |
| 525 | 492 | if($poster_show=='no'){ |
| @@ -525,22 +492,11 @@ | ||
| 525 | 492 | if($poster_show=='no'){ |
| 526 | 493 | $poster_data=''; |
| 527 | 494 | } |
| 528 | 495 | |
| 529 | - | |
| 530 | - $is_muted=''; | |
| 531 | - if( isset($event_settings['mute']) && intval($event_settings['mute'])==1){ | |
| 532 | - $is_muted=' muted '; | |
| 533 | - } | |
| 534 | - | |
| 535 | - | |
| 536 | - $autoplay='autoplay'; | |
| 537 | - if(isset($event_settings['autoplay']) && intval($event_settings['autoplay'])==0){ | |
| 538 | - $autoplay=''; | |
| 539 | - } | |
| 540 | - | |
| 496 | + | |
| 541 | 497 | echo' |
| 542 | - <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' '.$is_muted.' class="" > | |
| 498 | + <div iccd="player" id="wpstream-video'.$now.'" '.$poster_data.' class="" > | |
| 543 | 499 | </div>'; |
| 544 | 500 | |
| 545 | 501 | print '<script type="text/javascript"> |
| 546 | 502 | //<![CDATA[ |
| @@ -545,9 +501,9 @@ | ||
| 545 | 501 | print '<script type="text/javascript"> |
| 546 | 502 | //<![CDATA[ |
| 547 | 503 | jQuery(document).ready(function(){ |
| 548 | 504 | var low_latencyid="wpstream-video'.$now.'"; |
| 549 | - document.addEventListener("DOMContentLoaded", initPlayer(low_latencyid, "'.$hls_playback_url.'","'.$is_muted.'","'.$autoplay.'" ) ); '; | |
| 505 | + document.addEventListener("DOMContentLoaded", initPlayer(low_latencyid,"'.$live_event_uri_final.'") ); '; | |
| 550 | 506 | print'}); |
| 551 | 507 | //]]> |
| 552 | 508 | </script>'; |
| 553 | 509 | |
| @@ -552,9 +508,9 @@ | ||
| 552 | 508 | </script>'; |
| 553 | 509 | |
| 554 | 510 | |
| 555 | 511 | |
| 556 | - if(trim($hls_playback_url) ==''){ | |
| 512 | + if(trim($live_event_uri_final) ==''){ | |
| 557 | 513 | // $show_wpstream_not_live_mess=''; |
| 558 | 514 | }else{ |
| 559 | 515 | print '<script type="text/javascript"> |
| 560 | 516 | //<![CDATA[ |
| @@ -559,9 +515,9 @@ | ||
| 559 | 515 | print '<script type="text/javascript"> |
| 560 | 516 | //<![CDATA[ |
| 561 | 517 | jQuery(document).ready(function(){ |
| 562 | 518 | var player_wrapper = jQuery(".wpstream_live_player_wrapper"); |
| 563 | - wpstream_read_websocket_info("'.$channel_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chat_url.'", "'.$hls_playback_url.'"); | |
| 519 | + wpstream_read_websocket_info("'.$product_id.'","wpstream_live_player_wrapper'.$now.'", player_wrapper ,"'.$chatUrl.'", "'.$live_event_uri_final.'"); | |
| 564 | 520 | }); |
| 565 | 521 | //]]> |
| 566 | 522 | </script>'; |
| 567 | 523 | } |
| @@ -567,9 +523,9 @@ | ||
| 567 | 523 | } |
| 568 | 524 | |
| 569 | 525 | |
| 570 | 526 | if($use_chat=="yes"){ |
| 571 | - $this->wpstream_connect_to_chat($channel_id); | |
| 527 | + $this->wpstream_connect_to_chat($product_id); | |
| 572 | 528 | } |
| 573 | 529 | |
| 574 | 530 | usleep (10000); |
| 575 | 531 | |
| @@ -576,99 +532,128 @@ | ||
| 576 | 532 | } |
| 577 | 533 | |
| 578 | 534 | |
| 579 | 535 | |
| 580 | - | |
| 581 | - | |
| 582 | - /* | |
| 583 | - * | |
| 584 | - * Request HLS player | |
| 585 | - * | |
| 586 | - * | |
| 587 | - * | |
| 536 | + /** | |
| 537 | + * HLS PLAYER | |
| 538 | + * | |
| 539 | + * @author cretu | |
| 588 | 540 | */ |
| 589 | - public function wpstream_request_video_on_demand_hls_player($video_name,$product_id){ | |
| 590 | - if($video_name==''){ | |
| 591 | - return ''; | |
| 592 | - } | |
| 593 | - | |
| 594 | - $transient_name = 'wpstream_video_on_demand_'.$video_name; | |
| 595 | - $hls_to_return = get_transient( $transient_name ); | |
| 596 | - $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 ); | |
| 597 | 545 | |
| 598 | - | |
| 599 | - if($hls_to_return==false){ | |
| 600 | - | |
| 601 | - $access_token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 602 | - $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 | + } | |
| 603 | 557 | |
| 604 | - //corsorigin de check | |
| 605 | - $local_event_options = get_option('wpstream_user_streaming_global_channel_options') ; | |
| 606 | - $domain = parse_url ( get_site_url() ); | |
| 607 | - $domain_scheme = 'http'; | |
| 608 | - if(is_ssl()){ | |
| 609 | - $domain_scheme='https'; | |
| 558 | + | |
| 559 | + if($server_id==''){ | |
| 560 | + delete_transient($transient_name); | |
| 561 | + return '';exit(); | |
| 610 | 562 | } |
| 563 | + | |
| 564 | + $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/api20-livestrem/ap20_get_player_hls_dynamic/?access_token=".$token; | |
| 611 | 565 | |
| 612 | - $corsorigin=''; | |
| 613 | - if( isset($local_event_options['vod_domain_lock']) ){ | |
| 614 | - if (intval( $local_event_options['vod_domain_lock']) ==0 ){ | |
| 615 | - $corsorigin='*'; | |
| 616 | - } | |
| 617 | - }else{ | |
| 618 | - $corsorigin='*'; | |
| 566 | + | |
| 567 | + $arguments = array( | |
| 568 | + 'method' => 'GET', | |
| 569 | + 'timeout' => 45, | |
| 570 | + 'redirection' => 5, | |
| 571 | + 'httpversion' => '1.0', | |
| 572 | + 'blocking' => true, | |
| 573 | + 'headers' => array(), | |
| 574 | + 'body' => $values_array, | |
| 575 | + 'cookies' => array() | |
| 576 | + ); | |
| 577 | + $response = wp_remote_post($url,$arguments); | |
| 578 | + | |
| 579 | + $received_data = json_decode( wp_remote_retrieve_body($response) ,true); | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + if( isset($response['response']['code']) && $response['response']['code']=='200'){ | |
| 585 | + $hls_to_return = trim($received_data); | |
| 586 | + | |
| 587 | + | |
| 588 | + set_transient( $transient_name, $hls_to_return, 60 ); | |
| 589 | + return $hls_to_return; | |
| 590 | + }else{ | |
| 591 | + return 'failed connection'; | |
| 619 | 592 | } |
| 593 | + exit(); | |
| 594 | + }else{ | |
| 595 | + return $hls_to_return; | |
| 596 | + } | |
| 620 | 597 | |
| 621 | - if($corsorigin!='*'){ | |
| 622 | - $corsorigin=$domain_scheme.'://'.$domain['host']; | |
| 623 | - } | |
| 598 | + } | |
| 624 | 599 | |
| 625 | - $is_encrypt="false"; | |
| 626 | - if( isset($local_event_options['vod_encrypt']) && intval( $local_event_options['vod_encrypt']) ==1 ){ | |
| 627 | - $is_encrypt="true"; | |
| 628 | - } | |
| 629 | 600 | |
| 630 | - $hlsKeysUrlPrefix = get_site_url().'?wpstream_voddrm='; | |
| 631 | - $encrypt = $is_encrypt; | |
| 632 | - $debugDrm = false; | |
| 633 | 601 | |
| 634 | - $curl_post_fields=array( | |
| 635 | - 'access_token' => $access_token, | |
| 636 | - 'name' => $video_name, | |
| 637 | - 'corsOrigin' => $corsorigin, | |
| 638 | - 'encryptHls' => $encrypt, | |
| 639 | - 'hlsKeysUrlPrefix' => $hlsKeysUrlPrefix, | |
| 640 | - 'debugDrm' => $debugDrm, | |
| 602 | + /** | |
| 603 | + * HLS PLAYER | |
| 604 | + * | |
| 605 | + * @author cretu | |
| 606 | + */ | |
| 607 | + | |
| 608 | + | |
| 609 | + public function wpstream_request_hls_player($product_id){ | |
| 610 | + | |
| 611 | + $transient_name = 'hls_to_return_'.$product_id; | |
| 612 | + $hls_to_return = get_transient( $transient_name ); | |
| 613 | + | |
| 614 | + if ( false === $hls_to_return || $hls_to_return=='' ) { | |
| 615 | + | |
| 616 | + $show_id = intval($product_id); | |
| 617 | + $token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 618 | + $values_array = array(); | |
| 619 | + $values_array['show_id'] = $show_id; | |
| 620 | + | |
| 621 | + $url = WPSTREAM_CLUBLINKSSL."://www.".WPSTREAM_CLUBLINK."/wp-json/rcapi/v1/videos/ap20_get_player_hls/?access_token=".$token; | |
| 622 | + | |
| 623 | + | |
| 624 | + $arguments = array( | |
| 625 | + 'method' => 'GET', | |
| 626 | + 'timeout' => 45, | |
| 627 | + 'redirection' => 5, | |
| 628 | + 'httpversion' => '1.0', | |
| 629 | + 'blocking' => true, | |
| 630 | + 'headers' => array(), | |
| 631 | + 'body' => $values_array, | |
| 632 | + 'cookies' => array() | |
| 641 | 633 | ); |
| 634 | + $response = wp_remote_post($url,$arguments); | |
| 635 | + | |
| 636 | + $received_data = json_decode( wp_remote_retrieve_body($response) ,true); | |
| 642 | 637 | |
| 643 | - | |
| 644 | - $curl_response = $this->main->wpstream_live_connection->wpstream_baker_do_curl_base($url,$curl_post_fields); | |
| 645 | - $curl_response_decoded = json_decode($curl_response,JSON_OBJECT_AS_ARRAY); | |
| 646 | - | |
| 647 | - if($curl_response_decoded['success']){ | |
| 648 | - set_transient( $transient_name, $curl_response_decoded['hlsUrl'] ,300); | |
| 649 | - $hls_to_return = $curl_response_decoded['hlsUrl']; | |
| 650 | - if( isset($curl_response_decoded['hlsDecryptionKey']) && isset($curl_response_decoded['hlsDecryptionKeyIndex']) ){ | |
| 651 | - update_post_meta($product_id,'hlsDecryptionKey',$curl_response_decoded['hlsDecryptionKey']); | |
| 652 | - update_post_meta($product_id,'hlsDecryptionKeyIndex',$curl_response_decoded['hlsDecryptionKeyIndex']); | |
| 653 | - }else{ | |
| 654 | - delete_post_meta($product_id,'hlsDecryptionKey'); | |
| 655 | - delete_post_meta($product_id,'hlsDecryptionKeyIndex'); | |
| 656 | - } | |
| 657 | - | |
| 658 | - }else{ | |
| 659 | - return ''; | |
| 638 | + | |
| 639 | + | |
| 640 | + if( isset($response['response']['code']) && $response['response']['code']=='200'){ | |
| 641 | + $hls_to_return = trim($received_data); | |
| 642 | + set_transient( $transient_name, $hls_to_return, 60 ); | |
| 643 | + return $hls_to_return = trim($received_data); | |
| 644 | + }else{ | |
| 645 | + return 'failed connection'; | |
| 660 | 646 | } |
| 661 | - | |
| 647 | + exit(); | |
| 648 | + }else{ | |
| 649 | + return $hls_to_return; | |
| 662 | 650 | } |
| 663 | - | |
| 664 | - return $hls_to_return; | |
| 665 | - | |
| 651 | + | |
| 666 | 652 | } |
| 667 | 653 | |
| 668 | - | |
| 669 | - | |
| 670 | - | |
| 654 | + | |
| 655 | + | |
| 671 | 656 | /** |
| 672 | 657 | * VODPlayer uri details |
| 673 | 658 | * |
| 674 | 659 | * @author cretu |
| @@ -681,28 +666,38 @@ | ||
| 681 | 666 | * 1 - free live channel |
| 682 | 667 | * 2 - free video encrypted |
| 683 | 668 | * 3 - free video -not encrypted |
| 684 | 669 | */ |
| 685 | - | |
| 686 | - $post_type = get_post_type($product_id); | |
| 687 | - $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true)); | |
| 688 | - if( ( $post_type =='wpstream_product_vod' && $free_video_type==2 ) || get_post_type($product_id)=='product' ){ | |
| 670 | + $free_video_type = intval( get_post_meta($product_id, 'wpstream_product_type', true)); | |
| 671 | + | |
| 672 | + | |
| 673 | + if($free_video_type==2 || get_post_type($product_id)=='product' ){ | |
| 689 | 674 | |
| 690 | - /* | |
| 691 | - * IF vide is encrypted- readed from vod,streaner | |
| 692 | - * | |
| 693 | - */ | |
| 694 | - | |
| 675 | + /* IF vide is encrypted- readed from vod,streaner | |
| 676 | + */ | |
| 695 | 677 | |
| 696 | 678 | $video_type = 'application/x-mpegURL'; |
| 697 | 679 | $video_path = get_post_meta($product_id,'_movie_url',true); |
| 698 | - if(get_post_type($product_id)=='wpstream_product_vod'){ | |
| 680 | + if(get_post_type($product_id)=='wpstream_product'){ | |
| 699 | 681 | $video_path = esc_html(get_post_meta($product_id, 'wpstream_free_video', true)); |
| 700 | 682 | } |
| 701 | - $video_path_final = $this->wpstream_request_video_on_demand_hls_player($video_path,$product_id); | |
| 702 | 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 | + } | |
| 703 | 698 | |
| 704 | - }else if( $post_type =='wpstream_product_vod' && $free_video_type==3 ){ | |
| 699 | + }else if($free_video_type==3){ | |
| 705 | 700 | |
| 706 | 701 | /* Video is unecrypted - read from local or youtube / vimeo |
| 707 | 702 | */ |
| 708 | 703 | |
| @@ -712,22 +707,19 @@ | ||
| 712 | 707 | if (strpos($video_path_final, 'www.youtube') !== false) { |
| 713 | 708 | $wpstream_data_setup= ' data-setup=\'{ "techOrder": ["youtube"], "sources": [{ "type": "video/youtube", "src": "'.$video_path_final.'"}] }\' '; |
| 714 | 709 | $video_path_final=''; |
| 715 | 710 | } |
| 716 | - /* disabled due to old lib | |
| 717 | 711 | if (strpos($video_path_final, 'vimeo.com') !== false) { |
| 718 | 712 | $wpstream_data_setup= ' data-setup=\'{"techOrder": ["vimeo"], "sources": [{ "type": "video/vimeo", "src": "'.$video_path_final.'"}], "vimeo": { "color": "#fbc51b"} }\' '; |
| 719 | 713 | $video_path_final=''; |
| 720 | - }*/ | |
| 714 | + } | |
| 721 | 715 | |
| 722 | 716 | } |
| 723 | 717 | |
| 724 | - $return_array = array(); | |
| 718 | + $return_array=array(); | |
| 725 | 719 | $return_array['video_path_final'] = $video_path_final; |
| 726 | 720 | $return_array['wpstream_data_setup']= $wpstream_data_setup; |
| 727 | 721 | $return_array['video_type'] = $video_type; |
| 728 | - $return_array['free_video_type'] = $free_video_type; | |
| 729 | - $return_array['post_type'] = $post_type ; | |
| 730 | 722 | return $return_array; |
| 731 | 723 | } |
| 732 | 724 | |
| 733 | 725 | |
| @@ -743,94 +735,25 @@ | ||
| 743 | 735 | $uri_details = $this->wpstream_video_on_demand_player_uri_request($product_id); |
| 744 | 736 | $video_path_final = $uri_details['video_path_final']; |
| 745 | 737 | $wpstream_data_setup = $uri_details['wpstream_data_setup']; |
| 746 | 738 | $video_type = $uri_details['video_type']; |
| 747 | - $now = time().rand(0,1000000); | |
| 748 | 739 | |
| 749 | 740 | $thumb_id = get_post_thumbnail_id($product_id); |
| 750 | 741 | $thumb = wp_get_attachment_image_src($thumb_id,'small'); |
| 751 | 742 | $usernamestream = esc_html ( get_option('wpstream_api_username','') ); |
| 752 | 743 | |
| 753 | - $poster_thumb = ''; | |
| 754 | - if(isset($thumb[0])){ | |
| 755 | - $poster_thumb=$thumb[0]; | |
| 756 | - } | |
| 757 | - | |
| 758 | - $hlsDecryptionKey = get_post_meta($product_id,'hlsDecryptionKey',true); | |
| 759 | - $hlsDecryptionKeyIndex = get_post_meta($product_id,'hlsDecryptionKeyIndex',true); | |
| 760 | - | |
| 761 | - | |
| 762 | 744 | $pack = $this->main->wpstream_live_connection->wpstream_request_pack_data_per_user(); |
| 763 | - | |
| 764 | 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.'> | |
| 765 | 749 | |
| 766 | - $trailer_attachment_id = intval (get_post_meta( $product_id, 'video_trailer', true )); | |
| 767 | - $video_trailer = ''; | |
| 768 | - $video_trailer_type = ''; | |
| 769 | - if($trailer_attachment_id!=0) { | |
| 770 | - $video_trailer = wp_get_attachment_url( $trailer_attachment_id ); | |
| 771 | - $attachment_metadata = wp_get_attachment_metadata($trailer_attachment_id); | |
| 772 | - $video_trailer_type = $attachment_metadata['mime_type']; | |
| 773 | - } | |
| 774 | - | |
| 775 | - | |
| 776 | - | |
| 777 | - | |
| 778 | - if(isset($pack['available_data_mb']) && $pack['available_data_mb']>0){ | |
| 779 | - | |
| 780 | - if($video_path_final==''){ | |
| 781 | - if( $uri_details['post_type']=='wpstream_product_vod' && $uri_details['free_video_type']==3 ){ | |
| 782 | - }else{ | |
| 783 | - print '<div class="wpstream_vod_notice">This video does not exist or it has been deleted!</div>'; | |
| 784 | - } | |
| 785 | - | |
| 786 | - } | |
| 787 | - | |
| 788 | - // TODO (crerem) populate these from VOD settings | |
| 789 | - $autoplay = true; | |
| 790 | - $muted = false; | |
| 791 | - | |
| 792 | - echo '<video id="wpstream-video-vod-'.$now.'" class="video-js vjs-default-skin vjs-fluid kuk wpstream_video_on_demand vjs-wpstream" data-me="'.esc_attr($usernamestream).'" data-product-id="'.$product_id.'" playsinline preload="auto" | |
| 793 | - poster="'.esc_url($poster_thumb).'" '.$wpstream_data_setup.'> | |
| 750 | + <source src="'.trim($video_path_final).'" type="'.$video_type.'"> | |
| 794 | 751 | <p class="vjs-no-js"> |
| 795 | 752 | To view this video please enable JavaScript, and consider upgrading to a web browser that |
| 796 | 753 | <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a> |
| 797 | 754 | </p> |
| 798 | 755 | </video>'; |
| 799 | - | |
| 800 | - if($trailer_attachment_id !=0){ | |
| 801 | - print '<div id="wpstream_video_on_demand_play_trailer_btn_' . $now . '" class="wpstream_video_on_demand_play_video">'.esc_html('play trailer').'</div>'; | |
| 802 | - print '<div id="wpstream_video_on_demand_play_video_btn_' . $now . '" class="wpstream_video_on_demand_play_video">'.esc_html('play real video').'</div>'; | |
| 803 | - print '<script type="text/javascript"> | |
| 804 | - //<![CDATA[ | |
| 805 | - jQuery(document).ready(function(){ | |
| 806 | - wpstream_player_initialize_vod({ | |
| 807 | - videoElementId: "wpstream-video-vod-'.$now.'", | |
| 808 | - trailerUrl: "'.$video_trailer.'", | |
| 809 | - videoUrl: "'.$video_path_final.'", | |
| 810 | - autoplay: '.var_export($autoplay, true).', | |
| 811 | - muted: '.var_export($muted, true).', | |
| 812 | - playTrailerButtonElementId: "wpstream_video_on_demand_play_trailer_btn_'.$now.'", | |
| 813 | - playVideoButtonElementId: "wpstream_video_on_demand_play_video_btn_'.$now.'", | |
| 814 | - }); | |
| 815 | - }); | |
| 816 | - //]]> | |
| 817 | - </script>'; | |
| 818 | - } | |
| 819 | - else { | |
| 820 | - print '<script type="text/javascript"> | |
| 821 | - //<![CDATA[ | |
| 822 | - jQuery(document).ready(function(){ | |
| 823 | - wpstream_player_initialize_vod({ | |
| 824 | - videoElementId: "wpstream-video-vod-'.$now.'", | |
| 825 | - videoUrl: "'.$video_path_final.'", | |
| 826 | - autoplay: '.var_export($autoplay, true).', | |
| 827 | - muted: '.var_export($muted, true).', | |
| 828 | - }); | |
| 829 | - }); | |
| 830 | - //]]> | |
| 831 | - </script>'; | |
| 832 | - } | |
| 833 | 756 | }else{ |
| 834 | 757 | print esc_html_e('Insufficient resources to stream this title','wpstream'); |
| 835 | 758 | } |
| 836 | 759 | |
| @@ -841,224 +764,58 @@ | ||
| 841 | 764 | |
| 842 | 765 | |
| 843 | 766 | |
| 844 | 767 | /** |
| 845 | - * | |
| 846 | - * edited 4.0 | |
| 847 | - * | |
| 848 | 768 | * Retreive username for vod path |
| 849 | 769 | * |
| 850 | 770 | * @author cretu |
| 851 | 771 | */ |
| 852 | 772 | private function wpstream_retrive_username(){ |
| 853 | - | |
| 854 | - return get_option('wpstream_api_username_from_token'); | |
| 855 | - } | |
| 856 | - | |
| 857 | - /** | |
| 858 | - * check if the we can add display the player | |
| 859 | - * | |
| 860 | - * @since 3.12 | |
| 861 | - * returns html of the player | |
| 862 | - */ | |
| 863 | - | |
| 864 | - public function wpstream_check_if_player_can_dsplay($product_id){ | |
| 865 | - if ( is_user_logged_in() ) { | |
| 866 | - | |
| 867 | - $term_list = wp_get_post_terms($product_id, 'product_type'); | |
| 868 | - $current_user = wp_get_current_user(); | |
| 869 | - $subscription_model = intval( get_option('wpstream_global_sub','')) ; | |
| 870 | - | |
| 871 | - $product = wc_get_product($product_id); | |
| 872 | - $product_type = $product->get_type(); | |
| 873 | - | |
| 874 | - | |
| 875 | - if($subscription_model==1){ // if we have Neflix mode | |
| 876 | - if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode | |
| 877 | - return false; | |
| 878 | - } | |
| 879 | - if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){ | |
| 880 | - return true; | |
| 881 | - } | |
| 882 | - }else{ | |
| 883 | - // ppv mode | |
| 884 | - | |
| 885 | - if( $product_type=='subscription' ){ | |
| 886 | - | |
| 887 | -// $user_subscriptions = wcs_get_users_subscriptions($current_user->ID ); | |
| 888 | -// foreach ($user_subscriptions as $subscription) { | |
| 889 | -// $subscription_status = $subscription->get_status(); | |
| 890 | -// echo "</br>*** Subscription ID $subscription->ID for User ID $current_user->ID has status: $subscription_status"; | |
| 891 | -// } | |
| 773 | + $token = $this->main->wpstream_live_connection->wpstream_get_token(); | |
| 892 | 774 | |
| 893 | - | |
| 894 | - if( wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) { | |
| 895 | - // user has active subcription | |
| 896 | - return true; | |
| 897 | - } | |
| 898 | - | |
| 899 | - }else{ | |
| 900 | - if( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id)){ | |
| 901 | - return true; | |
| 902 | - } | |
| 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(); | |
| 903 | 792 | } |
| 904 | - | |
| 905 | - | |
| 906 | - } | |
| 907 | - return false; | |
| 908 | - | |
| 909 | 793 | } |
| 910 | - return false; | |
| 911 | 794 | |
| 912 | - } | |
| 913 | - | |
| 914 | 795 | |
| 915 | - | |
| 916 | - /** | |
| 917 | - * check if the we can add display the player - theme variant | |
| 918 | - * | |
| 919 | - * @since 3.12 | |
| 920 | - * returns html of the player | |
| 921 | - */ | |
| 922 | - public function wpstream_check_if_player_can_dsplay_theme($product_id){ | |
| 923 | - | |
| 924 | - $post_type= get_post_type($product_id); | |
| 925 | - | |
| 926 | - | |
| 927 | - print '------- post type: '.$post_type.'</br>'; | |
| 928 | - if($post_type=='wpstream_product_vod' || $post_type=='wpstream_product'){ | |
| 929 | - return true; // if we have free vod or live | |
| 930 | - } | |
| 931 | - | |
| 932 | - | |
| 933 | - | |
| 934 | - if ( is_user_logged_in() && $post_type==='product' ) { | |
| 935 | - | |
| 936 | - $product = wc_get_product( $product_id ); | |
| 937 | - $product_type = $product->get_type(); | |
| 938 | - $possible_bundle = get_post_meta($product_id, 'wpstream_part_of_bundle',true); | |
| 939 | - print '----------'.$product_type.'-----------</br>'; | |
| 940 | - | |
| 941 | - | |
| 942 | - | |
| 943 | - | |
| 944 | - $current_user = wp_get_current_user(); | |
| 945 | - $subscription_model = intval( get_option('wpstream_global_sub','')) ; | |
| 946 | - print 'subscription model '.$subscription_model.'</br>'; | |
| 947 | - | |
| 948 | - if($subscription_model==1){ // if we have Neflix mode | |
| 949 | - if( $product_type=='subscription' ){ // if the product loaded is a subscription and we are on netflix mode | |
| 950 | - return false; | |
| 951 | - } | |
| 952 | - if($this->wpstream_in_plugin_check_global_subscription_model($product_id)){ | |
| 953 | - return true; | |
| 954 | - } | |
| 955 | - }else{ | |
| 956 | - // ppv mode | |
| 957 | - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) ){ | |
| 958 | - return true; //simple product bought | |
| 959 | - }else if (function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ){ | |
| 960 | - return true; // subscription boght | |
| 961 | - }else if( get_post_type($product_id) =='product' && | |
| 962 | - intval($possible_bundle )!=0 && | |
| 963 | - wc_customer_bought_product( $current_user->user_email, $current_user->ID, $possible_bundle) | |
| 964 | - ){ | |
| 965 | - return true; // part of a boght bundle | |
| 966 | - } | |
| 967 | - } | |
| 968 | - print ' fac return false </br>'; | |
| 969 | - return false; | |
| 970 | - | |
| 971 | - } | |
| 972 | - return false; | |
| 973 | - | |
| 974 | - } | |
| 975 | 796 | |
| 976 | 797 | |
| 977 | - /** | |
| 978 | - * in plugin - check if global subscription model is enabled | |
| 979 | - * | |
| 980 | - * @since 3.12 | |
| 981 | - * | |
| 982 | - */ | |
| 983 | - public function wpstream_in_plugin_check_global_subscription_model($product_id) { | |
| 984 | 798 | |
| 985 | - // $selected_sub= get_post_meta($post->ID,'_wpstream_parent_sub',true); | |
| 986 | - if( is_user_logged_in() && function_exists('wcs_user_has_subscription') ){ | |
| 987 | - | |
| 988 | - global $woocommerce; | |
| 989 | - $current_user = wp_get_current_user(); | |
| 990 | - | |
| 991 | - $subscription_model = intval( get_option('wpstream_global_sub','')) ; | |
| 992 | - $main_subscription = intval( get_option('wpstream_global_sub_id','')); | |
| 993 | - | |
| 994 | - if($subscription_model==1){ | |
| 995 | - $selected_sub= get_post_meta($product_id,'_wpstream_parent_sub',true) ; | |
| 996 | - | |
| 997 | - if( is_array($selected_sub) ){ | |
| 998 | - | |
| 999 | - // we have per product sub | |
| 1000 | - foreach($selected_sub as $key=>$subscrition_id ): | |
| 1001 | - if( wcs_user_has_subscription( $current_user->ID, $subscrition_id ,'active') ) { | |
| 1002 | - return true; | |
| 1003 | - } | |
| 1004 | - endforeach; | |
| 1005 | - | |
| 1006 | - } else if($main_subscription!=0){ | |
| 1007 | - | |
| 1008 | - // if we have one main subscription | |
| 1009 | - if( wcs_user_has_subscription( $current_user->ID, $main_subscription ,'active') ) { | |
| 1010 | - return true; | |
| 1011 | - } | |
| 1012 | - } | |
| 1013 | - | |
| 1014 | - | |
| 1015 | - } | |
| 1016 | - return false; | |
| 1017 | - | |
| 1018 | - } | |
| 1019 | - // there is no woo subscription or user not logged in | |
| 1020 | - return false; | |
| 1021 | - } | |
| 1022 | - | |
| 1023 | - | |
| 1024 | - | |
| 1025 | - | |
| 1026 | - | |
| 1027 | - | |
| 1028 | - | |
| 1029 | - | |
| 1030 | - | |
| 1031 | 799 | /** |
| 1032 | - * | |
| 1033 | - * | |
| 1034 | - * | |
| 1035 | - * | |
| 1036 | - * check if the user bought the product and display the player - TO REDo | |
| 1037 | - * | |
| 1038 | - * @since 3.0.1 | |
| 800 | + * check if the user bought the product and display the player - TO REDo | |
| 801 | + * | |
| 802 | + * @since 3.0.1 | |
| 1039 | 803 | * returns html of the player |
| 1040 | - * | |
| 1041 | - * | |
| 1042 | - * | |
| 1043 | - * | |
| 1044 | - * | |
| 1045 | - */ | |
| 1046 | - public function wpstream_user_logged_in_product_already_bought($from_sh_id='') { | |
| 1047 | - if(function_exists('remove_wpstream_filter')){ | |
| 1048 | - return; | |
| 1049 | - } | |
| 1050 | - global $product; | |
| 1051 | - $product_id = $product->get_id(); | |
| 1052 | - $current_user = wp_get_current_user(); | |
| 804 | + */ | |
| 805 | + public function wpstream_user_logged_in_product_already_bought($from_sh_id='') { | |
| 1053 | 806 | |
| 1054 | 807 | if ( is_user_logged_in() ) { |
| 1055 | - | |
| 1056 | - | |
| 1057 | - if($this->wpstream_check_if_player_can_dsplay($product_id) ){ | |
| 1058 | - | |
| 1059 | - echo '<div class="wpstream_player_wrapper "><div class="wpstream_player_container">'; | |
| 808 | + global $product; | |
| 809 | + $current_user = wp_get_current_user(); | |
| 810 | + $product_id = $product->get_id(); | |
| 1060 | 811 | |
| 812 | + | |
| 813 | + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id) || ( function_exists('wcs_user_has_subscription') && wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) ){ | |
| 814 | + | |
| 815 | + | |
| 816 | + echo '<div class="wpstream_player_wrapper"><div class="wpstream_player_container">'; | |
| 817 | + | |
| 1061 | 818 | $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true)); |
| 1062 | 819 | $term_list = wp_get_post_terms($product_id, 'product_type'); |
| 1063 | 820 | |
| 1064 | 821 | |
| @@ -1068,45 +825,25 @@ | ||
| 1068 | 825 | $this->wpstream_video_on_demand_player($product_id); |
| 1069 | 826 | } |
| 1070 | 827 | echo '</div></div>'; |
| 1071 | 828 | }else{ |
| 1072 | - | |
| 1073 | - | |
| 1074 | - $term_list = wp_get_post_terms($product_id, 'product_type'); | |
| 1075 | - | |
| 1076 | - if( $term_list[0]->name=='subscription' ){ | |
| 1077 | - | |
| 1078 | - if( !wcs_user_has_subscription( $current_user->ID, $product_id ,'active') ) { | |
| 1079 | - $this->wpstream_display_no_buy_message('nobuy',$product_id); | |
| 1080 | - } | |
| 1081 | - | |
| 1082 | - }else{ | |
| 1083 | - $this->wpstream_display_no_buy_message('nobuy',$product_id); | |
| 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>'; | |
| 1084 | 833 | } |
| 1085 | - | |
| 1086 | - | |
| 1087 | - | |
| 1088 | 834 | } |
| 1089 | 835 | |
| 1090 | 836 | |
| 1091 | - }else{ | |
| 1092 | - | |
| 1093 | - $this->wpstream_display_no_buy_message('nolog',$product_id); | |
| 1094 | 837 | } |
| 1095 | 838 | } |
| 1096 | 839 | |
| 1097 | - | |
| 1098 | - | |
| 1099 | - | |
| 1100 | - | |
| 1101 | - /** | |
| 1102 | - * | |
| 1103 | - * | |
| 1104 | - * check if the user bought the product and display the player - TO REDo | |
| 1105 | - * | |
| 1106 | - * @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 | |
| 1107 | 844 | * returns html of the player |
| 1108 | - */ | |
| 845 | + */ | |
| 1109 | 846 | |
| 1110 | 847 | public function wpstream_chat_wrapper($product_id){ |
| 1111 | 848 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/templates/wpstream_chat_template.php'; |
| 1112 | 849 | } |
| @@ -1112,23 +849,9 @@ | ||
| 1112 | 849 | } |
| 1113 | 850 | |
| 1114 | 851 | |
| 1115 | 852 | |
| 1116 | - | |
| 1117 | - | |
| 1118 | - | |
| 1119 | - | |
| 1120 | - | |
| 1121 | - /** | |
| 1122 | - * coonect to chat | |
| 1123 | - * | |
| 1124 | - * @since 1.12.2 | |
| 1125 | - * | |
| 1126 | - */ | |
| 1127 | - | |
| 1128 | - | |
| 1129 | - | |
| 1130 | - public function wpstream_connect_to_chat($product_id){ | |
| 853 | + public function wpstream_connect_to_chat($product_id){ | |
| 1131 | 854 | $current_user = wp_get_current_user(); |
| 1132 | 855 | $userID = $current_user->ID; |
| 1133 | 856 | $user_login = $current_user->user_login; |
| 1134 | 857 | |
| @@ -1133,9 +856,9 @@ | ||
| 1133 | 856 | $user_login = $current_user->user_login; |
| 1134 | 857 | |
| 1135 | 858 | $key=''; |
| 1136 | 859 | |
| 1137 | - $chat_url = get_post_meta($product_id,'chat_url',true); | |
| 860 | + $chatUrl = get_post_meta($product_id,'chatUrl',true); | |
| 1138 | 861 | |
| 1139 | 862 | |
| 1140 | 863 | wp_enqueue_script( 'sockjs-0.3.min' ); |
| 1141 | 864 | wp_enqueue_script( 'emojione.min.js' ); |
| @@ -1155,9 +878,9 @@ | ||
| 1155 | 878 | |
| 1156 | 879 | |
| 1157 | 880 | if(!is_user_logged_in()){ |
| 1158 | 881 | $user_login=''; |
| 1159 | - $chat_url=''; | |
| 882 | + $chatUrl=''; | |
| 1160 | 883 | } |
| 1161 | 884 | |
| 1162 | 885 | |
| 1163 | 886 | print '<script type="text/javascript"> |
| @@ -1170,66 +893,5 @@ | ||
| 1170 | 893 | //]]> |
| 1171 | 894 | </script>'; |
| 1172 | 895 | |
| 1173 | 896 | } |
| 1174 | - | |
| 1175 | - | |
| 1176 | - /** | |
| 1177 | - * display no buy Message | |
| 1178 | - * | |
| 1179 | - * @since 3.12.2 | |
| 1180 | - * | |
| 1181 | - */ | |
| 1182 | - public function wpstream_display_no_buy_message($log,$product_id) { | |
| 1183 | - | |
| 1184 | - if($log=='sub_active'){ | |
| 1185 | - $message= esc_html( get_option('wpstream_subscription_active','Your Subscription is Active.')) ; | |
| 1186 | - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">'; | |
| 1187 | - echo '<div class="wpstream_notice"> '.$message.'</div>'; | |
| 1188 | - echo '</div></div>'; | |
| 1189 | - return; | |
| 1190 | - | |
| 1191 | - }else if($log=='nolog'){ | |
| 1192 | - $message= esc_html( get_option('wpstream_product_not_login','You must be logged in to watch this video.')) ; | |
| 1193 | - }else{ | |
| 1194 | - $message =esc_html( get_option('wpstream_product_not_bought','You did not yet purchase this item.')) ; | |
| 1195 | - } | |
| 1196 | - $subscription_model = intval( get_option('wpstream_global_sub','')) ; | |
| 1197 | - if($subscription_model==1){ | |
| 1198 | - $message =esc_html( get_option('wpstream_product_not_subscribe','You did not yet subscribe to this item.')); | |
| 1199 | - } | |
| 1200 | - | |
| 1201 | - | |
| 1202 | - if( get_post_type($product_id) == 'product' && $subscription_model==0 ){ | |
| 1203 | - $product = wc_get_product($product_id); | |
| 1204 | - $term_list = wp_get_post_terms($product_id, 'product_type'); | |
| 1205 | - $product_type = $product->get_type(); | |
| 1206 | - $is_subscription_live_event = esc_html(get_post_meta($product_id,'_subscript_live_event',true)); | |
| 1207 | - | |
| 1208 | - | |
| 1209 | - | |
| 1210 | - if( $term_list[0]->name=='video_on_demand' || $term_list[0]->name=='live_stream' || $product_type=='subscription'){ | |
| 1211 | - | |
| 1212 | - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">'; | |
| 1213 | - echo '<div class="wpstream_notice">'.$message.'</div>'; | |
| 1214 | - echo '</div></div>'; | |
| 1215 | - | |
| 1216 | - } | |
| 1217 | - | |
| 1218 | - }else if( get_post_type($product_id) == 'product' && $subscription_model==1 ){ | |
| 1219 | - $term_list = wp_get_post_terms($product_id, 'product_type'); | |
| 1220 | - if( $term_list[0]->name!=='simple'){ | |
| 1221 | - echo '<div class="wpstream_player_wrapper no_buy"><div class="wpstream_player_container">'; | |
| 1222 | - echo '<div class="wpstream_notice"> '.$message.'</div>'; | |
| 1223 | - echo '</div></div>'; | |
| 1224 | - } | |
| 1225 | - } | |
| 1226 | - | |
| 1227 | - | |
| 1228 | - | |
| 1229 | - | |
| 1230 | - | |
| 1231 | - | |
| 1232 | - } | |
| 1233 | - | |
| 1234 | - | |
| 1235 | -} | |
| 897 | +} | |