功能基本完成

This commit is contained in:
luyuan 2020-11-27 11:37:44 +08:00
parent 9f03cc4e30
commit 6ebea07f93
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
4 changed files with 79 additions and 8 deletions

View File

@ -273,25 +273,32 @@ function addVideoView(id, isLocal = false) {
function addMemberView(id) {
let memberElm = $('#member-me').clone();
memberElm.attr('id', id);
memberElm.find('div.member-id').html(id);
// memberElm.attr('class', id);
memberElm.css('display', 'flex');
memberElm.find("#video-btn").click((el)=>{
console.log(el)
console.log($(el.target).attr("src"))
const src = $(el.target).attr("src") == "img/camera-on.png" ? 1 : 0
console.log("video" + id);
sendsx(id,src)
})
memberElm.find("#mic-btn").click((el)=>{
console.log($(el.target).attr("src"))
const src = $(el.target).attr("src") == "img/mic-on.png" ? 1 : 0
console.log("mic" + id);
sendjinyan(id,src)
})
memberElm.find("#video-btn").removeAttr("id")
memberElm.find("#mic-btn").removeAttr("id")
console.log("移除")
memberElm.appendTo($('#member-list'));
getname(id).then((res)=>{
$("#" + id).find('div.member-id').html(res);
// console.log(.length)
})
memberElm.appendTo($('#member-list'));
}
function removeView(id) {
console.log("被删除")
if ($('#' + id)[0]) {
$('#' + id).remove();
//将video-grid中第一个div设为main-video

View File

@ -1,9 +1,31 @@
let options = {
SDKAppID: 1400435767 // 接入时需要将0替换为您的即时通信 IM 应用的 SDKAppID
};
let tim = TIM.create(options);
window.tim = TIM.create(options);
tim.setLogLevel(0);
function getname(id){
return new Promise((res, rej)=>{
let promise = tim.getGroupMemberProfile({
groupID:window.roomid,
userIDList:[id],
memberCustomFieldFilter:["nick"]
})
promise.then(function(imResponse) {
console.log(imResponse.data.memberList); // 群成员列表
res(imResponse.data.memberList[0].nick)
}).catch(function(imError) {
console.warn('getGroupMemberProfile error:', imError);
setTimeout(()=>{
getname(id).then((e)=>{
res(e)
})
},1000)
});
})
}
function formatDateTime (inputTime) {
inputTime = inputTime * 1000
var date = new Date(inputTime);
var y = date.getFullYear();
var m = date.getMonth() + 1;
@ -28,6 +50,9 @@ function formatDateTime (inputTime) {
if(!event.data[i].payload.text){
break;
}
if(event.data[i].payload.text.includes("beelinkMuteUserId") || event.data[i].payload.text.includes("inkTurnOffTheCameraUserId")){
break;
}
const list = $("#liaotianliebiao")
const html = ` <div>
<p>${formatDateTime(event.data[i].time)}</p>
@ -204,4 +229,42 @@ function formatDateTime (inputTime) {
});
function sendjinyan(id,type){
const m = tim.createTextMessage({
to: window.roomid,
conversationType: TIM.TYPES.CONV_GROUP,
payload: {
text: `beelinkMuteUserId:${id},isClose:${type}`
}
})
const promise = tim.sendMessage(m);
promise.then(function(imResponse) {
// 发送成功
console.log(imResponse);
}).catch(function(imError) {
// 发送失败
console.warn('sendMessage error:', imError);
});
}
function sendsx(id,type){
const m = tim.createTextMessage({
to: window.roomid,
conversationType: TIM.TYPES.CONV_GROUP,
payload: {
text: `beelinkTurnOffTheCameraUserId:${id},isClose:${type}`
}
})
const promise = tim.sendMessage(m);
promise.then(function(imResponse) {
// 发送成功
console.log(imResponse);
}).catch(function(imError) {
// 发送失败
console.warn('sendMessage error:', imError);
});
}
// 开始登录

View File

@ -205,6 +205,7 @@ class RtcClient {
const userId = evt.userId;
removeView(userId);
console.log('peer-leave ' + userId);
});
// fired when a remote stream is added
this.client_.on('stream-added', evt => {

View File

@ -422,8 +422,10 @@
$('body').bootstrapMaterialDesign();
});
</script>
<script src="./js/lib-generate-test-usersig.min.js"></script>
<script src="./js/debug/GenerateTestUserSig.js"></script>
<script src="./js/tim-js.js"></script>
<script src="./js/iminit.js"></script>
<script src="./js/lib-generate-test-usersig.min.js"></script>
<script src="./js/iconfont.js"></script>
<script src="./js/trtc.js"></script>
<script src="./js/common.js"></script>
@ -432,8 +434,6 @@
<script src="./js/presetting.js"></script>
<script src="./js/device-testing.js"></script>
<script src="./js/index.js"></script>
<script src="./js/tim-js.js"></script>
<script src="./js/iminit.js"></script>
</body>