| 1 |
/*global $, jQuery, wpstream_start_streaming_vars*/ |
| 2 |
var counters={}; |
| 3 |
|
| 4 |
jQuery(document).ready(function ($) { |
| 5 |
"use strict"; |
| 6 |
|
| 7 |
wpstream_check_live_connections(); |
| 8 |
wpestate_start_modal_actions(); |
| 9 |
wpestate_start_modal_error_actions(); |
| 10 |
wpstream_tooltip(); |
| 11 |
wpstream_copy_to_clipboard(); |
| 12 |
wpstream_webcaster_actions(); |
| 13 |
wpstream_save_options_actions(); |
| 14 |
wpstream_bind_start_and_stop(); |
| 15 |
|
| 16 |
wpstream_bind_stats_link(); |
| 17 |
|
| 18 |
|
| 19 |
}); |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
/* |
| 25 |
* |
| 26 |
* Bind block stats link |
| 27 |
* |
| 28 |
*/ |
| 29 |
|
| 30 |
function wpstream_bind_stats_link(){ |
| 31 |
|
| 32 |
jQuery('.wpstream_statistics_channel,.start_webcaster').each(function(event){ |
| 33 |
var selected_icon = jQuery(this); |
| 34 |
selected_icon.on('click',function(event){ |
| 35 |
if(selected_icon.hasClass('wpstream_inactive_icon')){ |
| 36 |
event.preventDefault(); |
| 37 |
event.stopPropagation(); |
| 38 |
} |
| 39 |
|
| 40 |
}); |
| 41 |
|
| 42 |
}) |
| 43 |
|
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
/* |
| 51 |
* |
| 52 |
* Bind Start and Stop channel |
| 53 |
* |
| 54 |
*/ |
| 55 |
|
| 56 |
|
| 57 |
function wpstream_bind_start_and_stop(){ |
| 58 |
|
| 59 |
jQuery('.start_event.wpstream_button').each(function(element){ |
| 60 |
var start_button=jQuery(this); |
| 61 |
wpstream_bind_start_event(start_button); |
| 62 |
}); |
| 63 |
|
| 64 |
|
| 65 |
jQuery('.wpstream_stop_event').each(function(element){ |
| 66 |
var stop_button=jQuery(this); |
| 67 |
wpstream_bind_stop_event(stop_button); |
| 68 |
}); |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
/* |
| 74 |
* |
| 75 |
* Bind start channel action |
| 76 |
* |
| 77 |
*/ |
| 78 |
var start_onboarding=''; |
| 79 |
function wpstream_bind_start_event(button){ |
| 80 |
|
| 81 |
button.click(function(event){ |
| 82 |
event.preventDefault(); |
| 83 |
button.unbind('click'); |
| 84 |
var ajaxurl = wpstream_start_streaming_vars.admin_url + 'admin-ajax.php'; |
| 85 |
var acesta = jQuery(this); |
| 86 |
var notification_area = jQuery(this).parent().find('.event_list_unit_notification'); |
| 87 |
var curent_content = jQuery(this).parent().find('.server_notification'); |
| 88 |
var is_record = false; |
| 89 |
var is_encrypt = false; |
| 90 |
var show_id = parseFloat( jQuery(this).attr('data-show-id') ); |
| 91 |
var nonce = jQuery('#wpstream_start_event_nonce').val(); |
| 92 |
var parent = jQuery(this).parent(); |
| 93 |
|
| 94 |
if( jQuery(this).parent().find('.record_event').is(":checked") ){ |
| 95 |
is_record = true; |
| 96 |
} |
| 97 |
|
| 98 |
if( jQuery(this).parent().find('.encrypt_event').is(":checked") ){ |
| 99 |
is_encrypt = true; |
| 100 |
} |
| 101 |
parent.find('.wpstream_show_settings').addClass('wpstream_inactive_icon'); |
| 102 |
jQuery(this).addClass('wpstream_turning_on').empty().html(wpstream_start_streaming_vars.start_streaming_action+'<div class="wpstream_loader"></div><div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turning_on_tooltip+'</div>'); |
| 103 |
parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_turning_on); |
| 104 |
|
| 105 |
jQuery.ajax({ |
| 106 |
type: 'POST', |
| 107 |
url: ajaxurl, |
| 108 |
dataType: 'json', |
| 109 |
timeout: 300000, |
| 110 |
|
| 111 |
data: { |
| 112 |
'action' : 'wpstream_give_me_live_uri', |
| 113 |
'security' : nonce, |
| 114 |
'show_id' : show_id, |
| 115 |
'is_record' : is_record, |
| 116 |
'is_encrypt' : is_encrypt, |
| 117 |
'start_onboarding' : start_onboarding, |
| 118 |
|
| 119 |
|
| 120 |
}, |
| 121 |
success: function (data) { |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
if(data.conected===true){ |
| 126 |
|
| 127 |
if(data.event_data==='err1'){ |
| 128 |
|
| 129 |
wpstream_show_error_on_start(wpstream_start_streaming_vars.error1,parent) |
| 130 |
|
| 131 |
}else if(data.event_data ==='failed event creation'){ |
| 132 |
|
| 133 |
wpstream_show_error_on_start(wpstream_start_streaming_vars.failed_event_creation,parent) |
| 134 |
|
| 135 |
}else{ |
| 136 |
curent_content.empty(); |
| 137 |
var counter = setInterval( function (){ |
| 138 |
wpstream_check_live_connections_on_start(parent,show_id,data.event_data,data)},10000); |
| 139 |
counters['stop'+show_id]=counter; |
| 140 |
|
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
}else{ |
| 145 |
wpstream_show_error_on_start(data.error,parent) |
| 146 |
} |
| 147 |
|
| 148 |
}, |
| 149 |
error: function (jqXHR,textStatus,errorThrown) { |
| 150 |
} |
| 151 |
}); |
| 152 |
|
| 153 |
}); |
| 154 |
|
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
/* |
| 159 |
* |
| 160 |
* Bind Stop channel action |
| 161 |
* |
| 162 |
*/ |
| 163 |
|
| 164 |
function wpstream_bind_stop_event(button){ |
| 165 |
button.click(function(event){ |
| 166 |
|
| 167 |
|
| 168 |
if(!confirm(wpstream_start_streaming_vars.turn_off_confirm)){ |
| 169 |
return false; |
| 170 |
} |
| 171 |
button.unbind('click'); |
| 172 |
|
| 173 |
|
| 174 |
var ajaxurl = wpstream_start_streaming_vars.admin_url + 'admin-ajax.php'; |
| 175 |
var show_id = parseFloat( jQuery(this).attr('data-show-id') ); |
| 176 |
var nonce = jQuery('#wpstream_start_event_nonce').val(); |
| 177 |
var parent = jQuery(this).parent(); |
| 178 |
var thisButton = jQuery(this); |
| 179 |
|
| 180 |
thisButton.removeClass('wpstream_stop_event'); |
| 181 |
thisButton.addClass('wpstream_turning_on').empty().html(wpstream_start_streaming_vars.stop_streaming_action+'<div class="wpstream_loader"></div><div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turning_off_tooltip+'</div>'); |
| 182 |
parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_turning_off); |
| 183 |
parent.find('.start_webcaster').addClass('wpstream_inactive_icon'); |
| 184 |
parent.find('.wpstream_stream_pro').addClass('wpstream_inactive_icon'); |
| 185 |
parent.find('.wpstream_live_data').addClass('wpstream_inactive_icon'); |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
jQuery.ajax({ |
| 190 |
type: 'POST', |
| 191 |
url: ajaxurl, |
| 192 |
dataType: 'json', |
| 193 |
timeout: 300000, |
| 194 |
|
| 195 |
data: { |
| 196 |
'action' : 'wpstream_turn_of_channel', |
| 197 |
'security' : nonce, |
| 198 |
'show_id' : show_id |
| 199 |
|
| 200 |
|
| 201 |
}, |
| 202 |
success: function (data) { |
| 203 |
|
| 204 |
if(data.conected===true){ |
| 205 |
|
| 206 |
thisButton.unbind('click'); |
| 207 |
|
| 208 |
var counter = setInterval( function (){ |
| 209 |
wpstream_check_live_connections_on_start(parent,show_id,'',data)},10000); |
| 210 |
counters["stop"+show_id]=counter; |
| 211 |
|
| 212 |
}else{ |
| 213 |
|
| 214 |
wpstream_show_error_on_stop(data.error,parent) |
| 215 |
} |
| 216 |
|
| 217 |
}, |
| 218 |
error: function (jqXHR,textStatus,errorThrown) { |
| 219 |
|
| 220 |
} |
| 221 |
}); |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
}); |
| 226 |
|
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
/* |
| 231 |
* |
| 232 |
* Enable copy to clipboard |
| 233 |
* |
| 234 |
*/ |
| 235 |
|
| 236 |
function wpstream_enable_cliboard(parent){ |
| 237 |
|
| 238 |
jQuery(parent).find('.copy_live_uri').click(function(){ |
| 239 |
|
| 240 |
var value_uri = jQuery(parent).find('.wpstream_live_uri_text').text(); |
| 241 |
var temp = jQuery("<input>"); |
| 242 |
jQuery("body").append(temp); |
| 243 |
jQuery(temp).val(value_uri).select(); |
| 244 |
document.execCommand("copy"); |
| 245 |
jQuery(temp).remove(); |
| 246 |
|
| 247 |
}); |
| 248 |
|
| 249 |
jQuery(parent).find('.copy_live_key').click(function(){ |
| 250 |
var value_uri = jQuery(parent).find('.wpstream_live_key_text').text(); |
| 251 |
var temp = jQuery("<input>"); |
| 252 |
jQuery("body").append(temp); |
| 253 |
jQuery(temp).val(value_uri).select(); |
| 254 |
document.execCommand("copy"); |
| 255 |
jQuery(temp).remove(); |
| 256 |
|
| 257 |
}); |
| 258 |
} |
| 259 |
|
| 260 |
|
| 261 |
/* |
| 262 |
* |
| 263 |
* Check live events/channels on starts |
| 264 |
* |
| 265 |
* |
| 266 |
* |
| 267 |
*/ |
| 268 |
|
| 269 |
|
| 270 |
function wpstream_check_live_connections_on_start( parent,show_id,server_id,data){ |
| 271 |
|
| 272 |
// server_url is dns change |
| 273 |
|
| 274 |
wpstream_check_event_status_in_js(show_id,'wpstream_check_live_connections_on_start', |
| 275 |
function(server_status){ |
| 276 |
|
| 277 |
if(server_status.status==='active' ){ |
| 278 |
|
| 279 |
|
| 280 |
wpstream_event_ready_make_actions_visible(parent); |
| 281 |
|
| 282 |
parent.find('.start_webcaster').attr('data-webcaster-url',server_status.webcaster_url); |
| 283 |
parent.find('.wpstream_live_uri_text').text(server_status.obs_uri); |
| 284 |
parent.find('.wpstream_live_key_text').text(server_status.obs_stream); |
| 285 |
|
| 286 |
var larix_rtmp= server_status.obs_uri+server_status.obs_stream; |
| 287 |
parent.find('.wpstream_larix_rtmp').text(larix_rtmp); |
| 288 |
|
| 289 |
var larix_qr ='larix://set/v1?conn[][url]='+encodeURIComponent(larix_rtmp); |
| 290 |
parent.find('.wpstream_start_with_larix_mobile').attr('href',larix_qr); |
| 291 |
|
| 292 |
parent.find('.wpstream_larix_rtmp').text(larix_rtmp); |
| 293 |
parent.find('.larrix_test').text(larix_rtmp); |
| 294 |
|
| 295 |
var print_qrcode= "https://chart.googleapis.com/chart?cht=qr&chs=110x110&chl="+encodeURIComponent(larix_qr) +"&choe=UTF-8"; |
| 296 |
parent.find('.print_qrcode').attr('src',print_qrcode); |
| 297 |
|
| 298 |
parent.parent().find('.wpstream_live_data').attr('href',server_status.live_data_url); |
| 299 |
clearInterval( counters["stop"+show_id]); |
| 300 |
|
| 301 |
|
| 302 |
}else if(server_status.status==='stopped' ){ |
| 303 |
|
| 304 |
clearInterval( counters["stop"+show_id]); |
| 305 |
wpstream_event_stopped_make_actions(parent); |
| 306 |
|
| 307 |
}else if(server_status.status==='error' ){ |
| 308 |
|
| 309 |
clearInterval( counters["stop"+show_id]); |
| 310 |
var curent_content = parent.find('.wpstream_channel_status'); |
| 311 |
curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'+wpstream_start_streaming_vars.failed_event_creation+'</div>'); |
| 312 |
} |
| 313 |
}); |
| 314 |
|
| 315 |
} |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
/* |
| 321 |
* check channell id status |
| 322 |
* |
| 323 |
* @param {type} channel_id |
| 324 |
* @param {type} callback |
| 325 |
* @returns {undefined} |
| 326 |
* |
| 327 |
* |
| 328 |
*/ |
| 329 |
|
| 330 |
function wpstream_check_event_status_in_js(channel_id,notes,callback){ |
| 331 |
|
| 332 |
var ajaxurl = wpstream_start_streaming_vars.admin_url + 'admin-ajax.php'; |
| 333 |
jQuery.ajax({ |
| 334 |
type: 'POST', |
| 335 |
dataType: 'json', |
| 336 |
url: ajaxurl, |
| 337 |
timeout: 3000000, |
| 338 |
|
| 339 |
data: { |
| 340 |
'action' : 'wpstream_check_event_status', |
| 341 |
'channel_id' : channel_id, |
| 342 |
'notes' : notes, |
| 343 |
|
| 344 |
}, |
| 345 |
success: function (data) { |
| 346 |
|
| 347 |
var obj = data; |
| 348 |
var channel_status = obj.status; |
| 349 |
|
| 350 |
if(channel_status=='active' || channel_status=='stopped' ){ |
| 351 |
callback(obj); |
| 352 |
}else if(channel_status=='error'){ |
| 353 |
callback(obj); |
| 354 |
}else{ |
| 355 |
callback(false); |
| 356 |
} |
| 357 |
|
| 358 |
}, error: function (jqXHR,textStatus,errorThrown) { |
| 359 |
|
| 360 |
} |
| 361 |
}); |
| 362 |
} |
| 363 |
|
| 364 |
|
| 365 |
/* |
| 366 |
* |
| 367 |
* Make actions visible on event if ready |
| 368 |
* |
| 369 |
* |
| 370 |
*/ |
| 371 |
function wpstream_event_ready_make_actions_visible(parent){ |
| 372 |
|
| 373 |
var actionButton = parent.find('.start_event'); |
| 374 |
parent.addClass('wpstream_show_started'); |
| 375 |
actionButton.unbind('click'); |
| 376 |
wpstream_bind_stop_event(actionButton); |
| 377 |
|
| 378 |
actionButton.addClass('wpstream_stop_event').removeClass('start_event').html(wpstream_start_streaming_vars.stop_streaming+'<div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turned_off_tooltip+'</div>'); |
| 379 |
parent.find('.wpstream-button-icon').removeClass('wpstream_inactive_icon'); |
| 380 |
parent.find('.wpstream_show_settings').addClass('wpstream_inactive_icon'); |
| 381 |
parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_on); |
| 382 |
|
| 383 |
//for onboarding |
| 384 |
var check_against='3'; |
| 385 |
var check_against_camera_icon='5'; |
| 386 |
if(jQuery('#woocommerce-product-data').length>0){ |
| 387 |
check_against='5' |
| 388 |
check_against_camera_icon='7'; |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
var bubble_Step =jQuery('#wpstream_onboard_bubble').attr('data-bubble-step'); |
| 393 |
|
| 394 |
if(bubble_Step===check_against){ |
| 395 |
jQuery('#wpstream_onboard_bubble_tile').text('Channel is now ON'); |
| 396 |
jQuery('#wpstream_onboard_bubble_content').text('You are ready to GO LIVE. Click Next to see how.'); |
| 397 |
} |
| 398 |
if(bubble_Step===check_against_camera_icon){ |
| 399 |
jQuery('#wpstream_onboard_bubble_tile').html('Go LIVE'); |
| 400 |
jQuery('#wpstream_onboard_bubble_content').html('To Go Live now, click the <div class=\"wpstream_sample_icon_settings wpstream_sample_icon_camera\"></div> icon. The broadcast app will open in a new window.'); |
| 401 |
|
| 402 |
if( jQuery('.event_list_unit .wpstream_button').hasClass('wpstream_stop_event') ){ |
| 403 |
jQuery('.wpstream_sample_icon_camera').css('cursor','pointer'); |
| 404 |
|
| 405 |
jQuery('.wpstream_sample_icon_camera').on('click',function(){ |
| 406 |
jQuery('.start_webcaster').trigger('click'); |
| 407 |
jQuery(this).unbind('click'); |
| 408 |
|
| 409 |
}) |
| 410 |
} |
| 411 |
|
| 412 |
} |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
/* |
| 417 |
* |
| 418 |
* Make actions visible on event if stopped |
| 419 |
* |
| 420 |
* |
| 421 |
*/ |
| 422 |
function wpstream_event_stopped_make_actions(parent){ |
| 423 |
|
| 424 |
var actionButton = parent.find('.wpstream_turning_on'); |
| 425 |
wpstream_bind_start_event(actionButton); |
| 426 |
parent.removeClass('wpstream_show_started'); |
| 427 |
actionButton.removeClass('wpstream_turning_on'); |
| 428 |
actionButton.addClass('start_event'); |
| 429 |
actionButton.html( wpstream_start_streaming_vars.start_streaming+'<div class="wpstream_tooltip">'+wpstream_start_streaming_vars.turned_on_tooltip+'</div>'); |
| 430 |
|
| 431 |
parent.find('.wpstream-button-icon').removeClass('wpstream_inactive_icon'); |
| 432 |
parent.find('.wpstream_stream_pro').addClass('wpstream_inactive_icon'); |
| 433 |
parent.find('.start_webcaster').addClass('wpstream_inactive_icon'); |
| 434 |
parent.find('.wpstream_statistics_channel').addClass('wpstream_inactive_icon'); |
| 435 |
|
| 436 |
parent.find('.wpstream_channel_status').text(wpstream_start_streaming_vars.channel_off); |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
function wpstream_show_error_on_start(text,parent){ |
| 442 |
//You don't have enough data to start a new event! |
| 443 |
jQuery('.wpstream_error_content').text(text); |
| 444 |
jQuery('.wpstream_modal_background').show(); |
| 445 |
jQuery('.wpstream_error_modal_notification').show(); |
| 446 |
wpstream_event_stopped_make_actions(parent); |
| 447 |
|
| 448 |
} |
| 449 |
|
| 450 |
function wpstream_show_error_on_stop(text,parent){ |
| 451 |
//You don't have enough data to start a new event! |
| 452 |
jQuery('.wpstream_error_content').text(text); |
| 453 |
jQuery('.wpstream_modal_background').show(); |
| 454 |
jQuery('.wpstream_error_modal_notification').show(); |
| 455 |
wpstream_event_ready_make_actions_visible(parent); |
| 456 |
|
| 457 |
} |
| 458 |
|
| 459 |
|
| 460 |
/* |
| 461 |
* |
| 462 |
* Streaming modal trigger functions |
| 463 |
* |
| 464 |
* |
| 465 |
*/ |
| 466 |
function wpestate_start_modal_actions(){ |
| 467 |
|
| 468 |
jQuery('.wpstream_close_modal').on('click',function(event){ |
| 469 |
jQuery(this).parent().hide(); |
| 470 |
jQuery('.wpstream_modal_background').hide(); |
| 471 |
}); |
| 472 |
|
| 473 |
document.addEventListener('keydown', function(event) { |
| 474 |
if(event.keyCode == 27){ |
| 475 |
jQuery('.wpstream_modal_form').hide(); |
| 476 |
jQuery('.wpstream_modal_background').hide(); |
| 477 |
} |
| 478 |
}); |
| 479 |
|
| 480 |
|
| 481 |
jQuery('.wpstream-trigger-modal').on('click',function(event){ |
| 482 |
|
| 483 |
if( jQuery(this).hasClass('wpstream_inactive_icon') ) { |
| 484 |
return; |
| 485 |
}; |
| 486 |
|
| 487 |
jQuery('.wpstream_modal_background').show(); |
| 488 |
var modal_class=jQuery(this).attr('data-modal'); |
| 489 |
var parent = jQuery(this).parent().parent(); |
| 490 |
jQuery('.wpstream_modal_background').show(); |
| 491 |
parent.find("."+modal_class).show(); |
| 492 |
}) |
| 493 |
|
| 494 |
jQuery('.wpstream_external_broadcast_options').change(function(event){ |
| 495 |
var new_option = jQuery(this).val(); |
| 496 |
var parent = jQuery(this).parent(); |
| 497 |
|
| 498 |
parent.find('.external_software_streaming').hide(); |
| 499 |
parent.find('.'+new_option).show(); |
| 500 |
}); |
| 501 |
|
| 502 |
|
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
/* |
| 508 |
* |
| 509 |
* Tooltips for buttons |
| 510 |
* |
| 511 |
* |
| 512 |
*/ |
| 513 |
|
| 514 |
function wpstream_tooltip(){ |
| 515 |
|
| 516 |
jQuery( ".wpstream_tooltip_wrapper" ).hover( |
| 517 |
function() { |
| 518 |
|
| 519 |
if(jQuery( this ).hasClass('wpstream_inactive_icon')){ |
| 520 |
jQuery( this ).find('.wpstream_tooltip_disabled').css('opacity',1); |
| 521 |
}else{ |
| 522 |
jQuery( this ).find('.wpstream_tooltip').css('opacity',1); |
| 523 |
} |
| 524 |
|
| 525 |
|
| 526 |
}, function() { |
| 527 |
jQuery( this ).find('.wpstream_tooltip').css('opacity',0); |
| 528 |
jQuery( this ).find('.wpstream_tooltip_disabled').css('opacity',0); |
| 529 |
} |
| 530 |
); |
| 531 |
} |
| 532 |
|
| 533 |
/* |
| 534 |
* |
| 535 |
* Modal errors |
| 536 |
* |
| 537 |
* |
| 538 |
*/ |
| 539 |
|
| 540 |
|
| 541 |
function wpestate_start_modal_error_actions(){ |
| 542 |
jQuery('.wpstream_error_ok').on('click',function(event){ |
| 543 |
jQuery(this).parent().hide(); |
| 544 |
jQuery('.wpstream_modal_background').hide(); |
| 545 |
jQuery(this).parent().find('.wpstream_error_content').text(''); |
| 546 |
}); |
| 547 |
} |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
/* |
| 553 |
* |
| 554 |
* Copy to Clipboard |
| 555 |
* |
| 556 |
* |
| 557 |
*/ |
| 558 |
|
| 559 |
function wpstream_copy_to_clipboard(){ |
| 560 |
|
| 561 |
jQuery('.copy_live_uri').click(function(){ |
| 562 |
var value_uri = jQuery(this).parent().find('.wpstream_live_uri_text').text(); |
| 563 |
var temp = jQuery("<input>"); |
| 564 |
jQuery("body").append(temp); |
| 565 |
jQuery(temp).val(value_uri).select(); |
| 566 |
document.execCommand("copy"); |
| 567 |
jQuery(temp).remove(); |
| 568 |
|
| 569 |
}); |
| 570 |
|
| 571 |
jQuery('.copy_live_key').click(function(){ |
| 572 |
var value_uri = jQuery(this).parent().find('.wpstream_live_key_text').text(); |
| 573 |
var temp = jQuery("<input>"); |
| 574 |
jQuery("body").append(temp); |
| 575 |
jQuery(temp).val(value_uri).select(); |
| 576 |
document.execCommand("copy"); |
| 577 |
jQuery(temp).remove(); |
| 578 |
}); |
| 579 |
} |
| 580 |
|
| 581 |
/* |
| 582 |
* |
| 583 |
* Webcaster button action |
| 584 |
* |
| 585 |
* |
| 586 |
*/ |
| 587 |
|
| 588 |
function wpstream_webcaster_actions(){ |
| 589 |
jQuery('.start_webcaster').on('click',function(){ |
| 590 |
if(jQuery(this).hasClass('wpstream_inactive_icon')){ |
| 591 |
return; |
| 592 |
} |
| 593 |
var caster_url = jQuery(this).attr('data-webcaster-url'); |
| 594 |
jQuery(this).parent().find('.external_software_streaming').slideUp() |
| 595 |
window.open(caster_url, '_blank', 'location=yes,scrollbars=yes,status=yes'); |
| 596 |
}) |
| 597 |
} |
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
/* |
| 603 |
* |
| 604 |
* Save options actions |
| 605 |
* |
| 606 |
* |
| 607 |
*/ |
| 608 |
|
| 609 |
function wpstream_save_options_actions(){ |
| 610 |
jQuery('.wpestate_settings_modal .wpstream_event_option_item').on('click',function(){ |
| 611 |
|
| 612 |
var holder = jQuery(this).parents('.wpstream_event_streaming_local'); |
| 613 |
var show_id = jQuery(this).parents('.event_list_unit').find('.start_event').attr('data-show-id'); |
| 614 |
var optionarray ={}; |
| 615 |
holder.find('.wpstream_event_option_item').each(function(){ |
| 616 |
optionarray[jQuery(this).attr('data-attr-ajaxname')]=jQuery(this).prop("checked") ? 1 : 0 ; |
| 617 |
}); |
| 618 |
|
| 619 |
var myJSON = JSON.stringify(optionarray); |
| 620 |
jQuery.ajax({ |
| 621 |
type: 'POST', |
| 622 |
url: ajaxurl, |
| 623 |
timeout: 300000, |
| 624 |
data: { |
| 625 |
'action' : 'wpstream_update_local_event_settings', |
| 626 |
'show_id' : show_id, |
| 627 |
'option' : optionarray, |
| 628 |
|
| 629 |
}, |
| 630 |
success: function (data) { |
| 631 |
}, |
| 632 |
error: function (jqXHR,textStatus,errorThrown) { |
| 633 |
} |
| 634 |
|
| 635 |
}); |
| 636 |
|
| 637 |
}); |
| 638 |
|
| 639 |
} |
| 640 |
|
| 641 |
|
| 642 |
/* |
| 643 |
* |
| 644 |
* Function to check live connections |
| 645 |
* |
| 646 |
* |
| 647 |
*/ |
| 648 |
|
| 649 |
function wpstream_check_live_connections(){ |
| 650 |
// was .pending_streaming.pending_trigger |
| 651 |
if( jQuery('.event_list_unit.pending_trigger').length>0 ){ |
| 652 |
jQuery('.event_list_unit.pending_trigger').each(function(){ |
| 653 |
var acesta = jQuery(this); |
| 654 |
var show_id = jQuery(this).attr('data-show-id'); |
| 655 |
var server_id = jQuery(this).attr('data-server-id'); |
| 656 |
|
| 657 |
wpstream_check_live_connections_from_database(acesta,show_id,server_id); |
| 658 |
var counter_long = ''; |
| 659 |
counter_long = setInterval( function (){ wpstream_check_live_connections_from_database(acesta,show_id,server_id)},60000); |
| 660 |
counters[show_id]=counter_long; |
| 661 |
|
| 662 |
}); |
| 663 |
} |
| 664 |
|
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
/* |
| 671 |
* |
| 672 |
* check live connection |
| 673 |
* |
| 674 |
* |
| 675 |
*/ |
| 676 |
|
| 677 |
|
| 678 |
function wpstream_check_live_connections_from_database( acesta,channel_id,server_id){ |
| 679 |
var server_status = wpstream_check_event_status_in_js(channel_id,'wpstream_check_live_connections_from_database', |
| 680 |
function(server_status){ |
| 681 |
|
| 682 |
if(server_status.status==='active' ){ |
| 683 |
wpstream_event_ready_make_actions_visible( acesta ); |
| 684 |
acesta.find('.wpstream_ready_to_stream .start_webcaster').attr('data-webcaster-url',server_status.webcaster_url); |
| 685 |
acesta.find('.wpstream_live_uri_text').text(server_status.obs_uri); |
| 686 |
acesta.find('.wpstream_live_key_text').text(server_status.obs_stream); |
| 687 |
|
| 688 |
var larix_rtmp= server_status.obs_uri+server_status.obs_stream; |
| 689 |
acesta.find('.wpstream_larix_rtmp').text(larix_rtmp); |
| 690 |
|
| 691 |
acesta.find('.larrix_test').text(larix_rtmp); |
| 692 |
|
| 693 |
var larix_qr ='larix://set/v1?conn[][url]='+encodeURIComponent(larix_rtmp); |
| 694 |
acesta.find('.wpstream_start_with_larix_mobile').attr('href',larix_qr); |
| 695 |
|
| 696 |
var print_qrcode= "https://chart.googleapis.com/chart?cht=qr&chs=110x110&chl="+encodeURIComponent(larix_qr) +"&choe=UTF-8"; |
| 697 |
|
| 698 |
acesta.find('.print_qrcode').attr('src',print_qrcode); |
| 699 |
acesta.find('.wpstream_live_data').attr('href',server_status.live_data_url); |
| 700 |
clearInterval( counters["stop"+channel_id]); |
| 701 |
|
| 702 |
}else if(server_status.status==='error' ){ |
| 703 |
|
| 704 |
clearInterval( counters["stop"+channel_id]); |
| 705 |
var curent_content = acesta.find('.wpstream_channel_status '); |
| 706 |
|
| 707 |
curent_content.html('<div class="wpstream_channel_status not_ready_to_stream"><span class="dashicons dashicons-dismiss"></span>'+wpstream_start_streaming_vars.failed_event_creation+'</div>'); |
| 708 |
} |
| 709 |
}); |
| 710 |
|
| 711 |
} |
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
/* |
| 716 |
* |
| 717 |
* Check event/channel status |
| 718 |
* |
| 719 |
* |
| 720 |
*/ |
| 721 |
|
| 722 |
|
| 723 |
function wpstream_check_server_status(url_param,callback) { |
| 724 |
|
| 725 |
var url = url_param ; |
| 726 |
var status=''; |
| 727 |
jQuery.ajax({ |
| 728 |
url: url, |
| 729 |
type: "get", |
| 730 |
cache: false, |
| 731 |
dataType: 'jsonp', // it is for supporting crossdomain |
| 732 |
crossDomain : true, |
| 733 |
asynchronous : false, |
| 734 |
timeout : 1500, // set a timeout in milliseconds |
| 735 |
callback:'', |
| 736 |
complete : function(xhr) { |
| 737 |
|
| 738 |
if(xhr.status == "200" || xhr.status == "400") { |
| 739 |
callback(true); |
| 740 |
} |
| 741 |
else { |
| 742 |
callback(false); |
| 743 |
} |
| 744 |
} |
| 745 |
}); |
| 746 |
} |
| 747 |
|