live.js 13.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
function toSubmit(){
	$("#activityForm").submit();
}
	
//修改直播开始结束时间
function update_activity_time(){
	var start_time= $('#start_time').val();
	var end_time= $('#end_time').val();
	var id=$('#activity_id').val();
	$.ajax({
		url : BASE+'/activity/update/time/',
		type : 'post',
		async : true,
		error : function() {
			alert("请求错误");
		    console.log(XMLHttpRequest.status);    
		    console.log(XMLHttpRequest.readyState);    
		},
		data : {
			id :id,
			start_time :start_time,
			end_time:end_time
		},
		success : function(data) {
			$("#update_time_btn").html("保存成功");
			$("#update_time_btn").attr("disabled", true);
		}
	});
}

function preload_wowza(id){
	window.location.href=BASE+ "/activity/preloadWowza/"+id;
} 
function t_live_edit(id){
	window.location.href=BASE+ "/live/edit/"+id;
}


function to_step_before(id){
	window.location.href=BASE+ "/activity/stepBefore/"+id;
}

function to_step_in(id){
	window.location.href=BASE+ "/activity/stepIn/"+id;
}

function to_step_after(id){
	window.location.href=BASE+ "/activity/stepAfter/"+id;
}
  
function show_time_div(){
	var state  =$("#eidt_time_li").css('display');
	if (state=='none') {
		$("#eidt_time_li").show();
	}else{
		$("#eidt_time_li").hide();
	}
}

function to_stop(id){
	$("#reset_btn").html("后台处理中...");
	$("#reset_btn").attr("disabled", "disabled");
	$.ajax({
		url : BASE+'/activity/stop/'+id,
		type : 'get',
		datatype : "json",
		async : true,
		error : function() {
			alert("请求错误");
		    console.log(XMLHttpRequest.status);  
			$("#reset_btn").html("复位中...");
		},
		success : function(data) {
			if (data.success) {
				$("#reset_btn").html("信号已复位");
				$("#publish_div").html("");
				var btn='<button type="button" id="publishreview_btn" style="width: 250px; height: 100px" class="btn btn-block btn-lg  btn-warning" onclick="do_publishreview(${tActivity.id});" class="btn  btn-warning">发布直播回放</button>';
				$("#publish_div").html("");
			}else{
				$("#reset_btn").html("信号复位失败,或者活动已经结束");
			}
		}
	});
	
}
//获取tree 所选值
//function select_wowza_signal(){
//	var tree_node=$(".easy-tree").find('li.li_selected');
//	var id=tree_node.attr('id');
//	$("#t_wowza_stream_id_tip").val(tree_node.text());
//	$("#t_wowza_stream_id").val(id);
//	$("#wowza_modal").modal('hide');
//}

function copy_name(){
	var name=$('#name').val();
	$('#epg_name').val(name);
}


function save_confirm(){
	var start_time= $('#start_time').val();
	console.log(start_time);
	var t_wowza_stream_id_tip=$("#t_wowza_stream_id_tip").val();
	var channel_names=""; 
	$("input[name='channel_id']:checked").each(function(){ 
		channel_names+=$(this).attr("title")+"  、"; 
	}) 
	var html="<p  class=\"lead\"><h4>预计将在: <code>"+start_time+"</code></h4></p><p  class=\"lead\"><h4>将信号: <code>"+t_wowza_stream_id_tip+"</code></h4></p><p  class=\"lead\"><h4>切换至: <code>"+channel_names+"</code></h4></p>";
	$("#tip_message").html(html);
	$("#save_confirm_modal").modal({backdrop: 'static', keyboard: false});
}




function  t_activity_save_or_update(id){
	$("#t_activity_save_btn").html("后台处理中...");
	//$("#t_activity_save_btn").attr("disabled", "disabled");
	var is_free;
	$("input[name='is_free']:checked").each(function() {
		is_free = this.value;
	});
	var is_playback;
	$("input[name='is_playback']:checked").each(function() {
		is_playback = this.value;
	});
	
	var logo;
	$("input[name='logo']:checked").each(function() {
		logo = this.value;
	});
	
	var channel_ids=""; 
	$("input[name='channel_id']:checked").each(function(){ 
		channel_ids+=$(this).val()+","; 
	}) 
	var is_main= $('#is_main').val();
	var t_activity = new Object();
	t_activity.name = $('#name').val();
	t_activity.epg_name = $('#epg_name').val();
	t_activity.description = $('#description').val();
	t_activity.place = $('#place').val();
	t_activity.start_time = $('#start_time').val();
	t_activity.end_time = $('#end_time').val();
	t_activity.contact_user =$('#contact_user').val();
	t_activity.v_count = $('#v_count').val();
	t_activity.is_free=is_free;
	t_activity.t_default_video_id=$("#t_default_video_id  option:selected").val();
	t_activity.is_playback=is_playback;
	t_activity.logo=logo;
	t_activity.uuid= $('#uuid').val();
	t_activity.notify_user=$('#notify_user').val();
	t_activity.chatroom_id=$('#chatroom_id').val();
	var json = JSON.stringify(t_activity);
	$.ajax({
		url : BASE+'/activity/add',
		type : 'post',
		datatype : "json",
		data : {
			id :id,
			json :json,
			is_main:is_main,
			channel_ids:channel_ids
		},
		async : true,
		error : function() {
			alert("请求错误");
		    console.log(XMLHttpRequest.status);    
		    console.log(XMLHttpRequest.readyState);    
		},
		success : function(data) {
			$("#t_activity_save_btn").html("保存成功");
			$("#t_activity_save_btn").attr("disabled", true);
			showTip(data.success);
			location.href = BASE+'/activity/list/1';
		}
	});
	$("#save_confirm_modal").modal('hide');
}

//为活动添加wowza信号
function append_wowza(id){
	$("#append_wowza_btn").html("保存中...");
	$("#append_wowza_btn").attr("disabled", "disabled");
	var t_wowza_stream_id;
	$("input[name='t_wowza_stream_id']:checked").each(function() {
		t_wowza_stream_id = this.value;
	});
	if(t_wowza_stream_id==''){
		alert("请选择对应是 wowza  stream");
	}else{
			$.ajax({
			url : BASE+'/activity/appendStream',
			type : 'post',
			data : {
				id :id,
				t_wowza_stream_id:t_wowza_stream_id
			},
			async : true,
			error : function() {
				alert("请求错误");
			    console.log(XMLHttpRequest.status);    
			    console.log(XMLHttpRequest.readyState);    
			},
			success : function(data) {
				var fla=data.success;
				if(fla){
					$("#append_wowza_btn").html("保存成功");
					$("#append_wowza_btn").attr("disabled", true);
					showTip(fla);
					location.href = BASE+'/activity/list/1';
				}else{
					showTipWidthMsg(true,"请先为该活动指定输出频道,去修改直播活动!");
				}
			}
		});
	}
}

function  t_activity_search(oid){
	$("#t_activity_search_btn").html("后台处理中...");
	$("#t_activity_search_btn").attr("disabled", "disabled");
	var search_text= $('#search_text').val();
	$.ajax({
		url : BASE+'/activity/search/1',
		type : 'post',
		data : {
			name :search_text
		},
		async : true,
		error : function() {
			alert('搜索发生错误!');
			$("#t_activity_search_btn").attr("disabled", false);
		},
		success : function(data) {
			 
		}
	});
}

//新建活动时选择输出频道
function select_channel(id){
	var div =$("#div_channel_box_"+id);
	var div_inner_checkbox=div.find("input[type='checkbox']")
	var is_checked=div_inner_checkbox.is(':checked');
	if (is_checked) {
		//取消选择
		 div.removeClass().addClass("small-box bg-aqua");
		 div_inner_checkbox.iCheck('uncheck');
	}else{
		div_inner_checkbox.iCheck('check'); 
		div.removeClass().addClass("small-box bg-red");
	}
}
function isMainClick(obj){
	alert(obj);
	
}

function t_activity_delete(id) {
	if (window.confirm('您确定要删除吗!')) {
		$.ajax({
			url :  BASE+'/activity/delete/' + id,
			type : 'get',
			async : true,
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert("请求错误");
			    console.log(XMLHttpRequest.status);    
			    console.log(XMLHttpRequest.readyState);    
			    console.log(textStatus);
			},
			success : function(data) {
				if (data.success) {
					location.href = BASE+'/activity/list/1';
				} else {
					showTipWidthMsg(true,"删除失败!    "+data.data);
				}
			}
		});
	}
}


function val_file(id){
	$.ajax({
		url : BASE+'/wowza/valfile/'+id,
		type : 'get',
		datatype : "json",
		async : true,
		error : function() {
			alert("请求错误");
		    console.log(XMLHttpRequest.status);    
		    console.log(XMLHttpRequest.readyState);    
		    console.log(textStatus);
		},
		success : function(data) {
			//showTip(data.success);
		}
	});
}

function replace_epg(id){
	$("#btn_replace_epg").html("后台处理中...");
	$.ajax({
		url : BASE+'/activity/epg/'+id,
		type : 'get',
		datatype : "json",
		async : true,
		error : function() {
			alert("请求错误");
		    console.log(XMLHttpRequest.status);    
		    console.log(XMLHttpRequest.readyState);    
		},
		success : function(data) {
			 showTip(data.success);
			 $("#btn_replace_epg").attr("disabled", "disabled");
			 $("#btn_replace_epg").html("替换完成");
		}
	});
}
//详情页信号切换
function  do_switch(id){
	$("#switch_btn").html("后台处理中...");
	$("#switch_btn").attr("disabled", "disabled");
	$.ajax({
		url : BASE+'/activity/doswitch/'+id,
		type : 'get',
		async : true,
		error : function() {
			alert('发生错误!');
			$("#switch_btn").html("切换失败!");
			$("#switch_btn").attr("disabled", false);
		},
		success : function(data) {
			$("#switch_btn").html("切换成功");
			$("#switch_btn").attr("disabled", false);
		}
	});
}

//详情页-撤销 $("input[name='keleyicom']")
function  do_stop(id){
	$("#reset_btn").html("后台处理中...");
	$("#reset_btn").attr("disabled", "disabled");
	$.ajax({
		url : BASE+'/activity/stop/'+id,
		type : 'get',
		async : true,
		error : function() {
			alert('发生错误!');
			$("#reset_btn").html("信号复位失败!");
			$("#reset_btn").attr("disabled", false);
		},
		success : function(data) {
			$("#reset_btn").html("信号复位成功");
			$("#reset_btn").attr("disabled", false);
		}
	});
}
//详情页-紧急垫片
function  do_ad(id){
	$("button[name='ad_btn']").html("后台处理中...");
	$("button[name='ad_btn']").attr("disabled", "disabled");
	$.ajax({
		url : BASE+'/activity/advideo/'+id,
		type : 'get',
		async : true,
		error : function() {
			alert('发生错误!');
			$("button[name='ad_btn']").html("垫片失败!");
			$("button[name='ad_btn']").attr("disabled", false);
		},
		success : function(data) {
			if(data.success){
				$("button[name='ad_btn']").html("垫片成功");
				//$("#switch_btn").attr("disabled", false);
			}else{
				$("button[name='ad_btn']").html("垫片失败,请检查是否活动已经结束,或者当前活动是否分配直播频道");
				$("#switch_btn").attr("disabled", false);
			}
		}
	});
}


//获取录制视频文件信息
function  do_checkfile(id){
	$("#checkfile_btn").html("后台处理中...");
	$("#checkfile_btn").attr("disabled", "disabled");
	$.ajax({
		url : BASE+'/activity/checkfile/'+id,
		type : 'get',
		async : true,
		error : function() {
			alert('发生错误!');
			$("#checkfile_btn").html("验证文件失败!");
			$("#checkfile_btn").attr("disabled", false);
		},
		success : function(data) {
				var jsonData=data.data;
				if (jsonData==null) {
					$("#mp4_info").append("没有文件产生");
				}else{
					 $.each(jsonData, function(idx, name){
						  var html='<hr><a class="btn btn-primary btn-xs">文件名:'+name+'</a>';
						  $("#mp4_info").append(html);
					}); 
					 
					$("#checkfile_btn").html("验证完成");
					$("#checkfile_btn").attr("disabled", false);
				}
		}
	});
}


// 发布直播回放
function  do_publishreview(id){
	$("#publishreview_btn").html("后台处理中...");
	$("#publishreview_btn").attr("disabled", "disabled");
	$.ajax({
		url : BASE+'/activity/publishReview/'+id,
		type : 'get',
		async : true,
		error : function() {
			alert('发生错误!');
			$("#publishreview_btn").html("信号复位失败!");
			$("#publishreview_btn").attr("disabled", false);
		},
		success : function(data) {
			$("#publishreview_btn").html("发布成功");
			//$("#publishreview_btn").attr("disabled", false);
		}
	});
}
//断流处理
function play_close(id,live_url,uuid){
	$.ajax({
		url : '../../check/cut/' + id,
		type : 'post',
		datatype : "json",
		async : true,
		data:{"live_url":live_url,
			"uuid":uuid,
		},
		error : function() {
			alert('关闭时发生错误!');
		},
		success : function(data) {
			//$("#play_url_"+id).val("");
			location.href = '../../check/list/1';
			alert("关闭成功");
		}
	});
}
function changePlay(id,live_url,userId,title,time){
	$("input").attr("id","play_url_"+id);
	$("input").attr("name","play_url_"+id);
	$("#hidId").val(live_url);
	$("li[id='userId']").html("<a><i class='fa fa-file-text-o'></i>用户ID: "+userId+"</a>");
	$("li[id='title']").html("<a><i class='fa fa-file-text-o'></i>TITLE: "+title+"</a>");
	$("li[id='startTime']").html("<a><i class='fa fa-file-text-o'></i>开播时间: "+time+"</a>");
	jwplayer("playId").setup({ 
		    file: live_url, 
		    height: 260, 
		    //image: "/assets/myVideo.jpg", 
		    autostart:true,
		    rtmp: { 
		        bufferlength: 0.1 
		    }, 
		    width: 370 
		});

}
function t_live_xq(id){
	window.location.href="../../video/view/"+id;
}
function t_live_underLine(id){
	$.ajax({
		url:'../../video/unline',
		type:'post',
		datatype : 'json',
		data:{"id":id},
		error : function() {
			alert('下线时发生错误!');
		},
		success : function(data) {
			location.href = '../../video/check/1';
			alert("下线成功");
		}
	});
}
function checkUser(){
	 var search_user_id = $("#search_user_id").val();
	 var search_title = $("#search_title").val();
	 $.ajax({
			url:'../../live/search/1',
			type:'post',
			datatype : 'json',
			error : function() {
				alert('下线时发生错误!');
			},
			success : function(data) {
				//location.href = "../../live/search/1?search_user_id="+search_user_id+"&search_title="+search_title;
				//alert(location.href);
			}
		});
}