You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var isCall,iCount;
let rtc = null;
//相关接口前缀
var demoRoot = window._CONFIG['videoInterface'];
//发起视频通话的用户id 大屏发起请求保证和用户账户id不重复即可
let applyId="1173";//重重重,这里写死9999吧,这样我们会把你标记成大屏
//发起视频通话的用户名称
let applyUser = "联动中心";
//房间号
let roomId="";
//拨打对象id 账号/密码safesoftDemo/666666
let userId = ""
//拨打对象名称
let userName = "";
//发起通话
$(function(){
let obj= GetRequest()
roomId = obj.id//拨打对象id
userId = obj.id//拨打对象id
userName = obj.name//拨打对象name
openVideoCall()
})
function GetRequest() {
var url = location.search; //获取url中"?"符后的字串
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for(var i = 0; i < strs.length; i ++) {
theRequest[strs[i].split("=")[0]]=decodeURIComponent(strs[i].split("=")[1]);
}
}
return theRequest;
}
function openVideoCall() {
console.log(window)
// $('#spth_win').show();
//拨打对象名称展示
$('#spth_caller').html(userName);
isCall = 1;
var config = genTestUserSig(applyId);
//发送通话请求,数据库加一条通话请求数据
$.ajax({
url: demoRoot + 'video/call/apply',
type: 'post',
contentType: 'application/json',
data: JSON.stringify({
applyId: applyId,
userId: userId,
roomId: roomId,
applyUser: applyUser,
acceptUser: userName
}),
dataType: 'json',
success: function (data) {
//js sdk 配置
rtc = new RtcClient({
userId: applyId,//用户id-------↓-----------唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点
roomId: userId,//房间号 roomId修改为userId
sdkAppId: config.sdkAppId,//---↑-----------唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点,唯一修改点
userSig: config.userSig
});
rtc.join();//推流
//轮询数据库判断app是否挂断
iCount = setInterval("callExist(" + applyId + "," + roomId + ")", "3000");
},
error: function () {
}
});
}
//查询app是否挂断
function callExist(userId, roomId) {
$.ajax({
url: demoRoot + 'video/call/exist',
type: 'post',
data: {
applyId: userId,
roomId: roomId
},
dataType: 'json',
success: function (data) {
if (data == false) {
clearInterval(iCount);
if (isCall == 1) {
window.parent['goBack']()
}
if(rtc){
rtc.leave();
rtc = null;
}
$('#spth_win_all').hide();
$('#spth_win').hide();
}
},
error: function () {
}
});
}
//关闭视屏通话
function closeVideoCall() {
$.ajax({
url: demoRoot + 'video/call/end',
type: 'post',
contentType: 'application/json',
data: JSON.stringify({
applyId: applyId,
userId: userId,
roomId: roomId,
applyUser: applyUser,
acceptUser: userName
}),
dataType: 'json',
success: function () {
isCall = 0;
rtc.leave();
rtc = null;
},
error: function () {
}
});
window.parent['goBack']()
}