yj #1
|
|
@ -185,78 +185,7 @@ const Meeting: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
setMeetingMode('StandardMode');
|
setMeetingMode('StandardMode');
|
||||||
agora.init(true)
|
agoraInit()
|
||||||
agora.registerEventHandler({
|
|
||||||
onJoinChannelSuccess: async (info: any, _elapsed: any) => {
|
|
||||||
if (info.channelId === state.channelId) {
|
|
||||||
if (String(info.localUid).length !== 9) {
|
|
||||||
await getJoin(state.enableMicr, state.enableCamera)
|
|
||||||
setTimeout(async () => {
|
|
||||||
await agora.setupLocalVideo({
|
|
||||||
uid: Number(info.localUid),
|
|
||||||
view: document.getElementById(`video-${info.localUid}`),
|
|
||||||
channelId: info.channelId,
|
|
||||||
sourceType: VideoSourceType.VideoSourceCameraPrimary,
|
|
||||||
})
|
|
||||||
getShowUser();
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
|
||||||
if (info.channelId === state.channelId) {
|
|
||||||
if (String(remoteUid).length === 9) {
|
|
||||||
setIsShare(remoteUid)
|
|
||||||
} else {
|
|
||||||
setTimeout(async () => {
|
|
||||||
await agora.setupRemoteVideoJoin({
|
|
||||||
uid: Number(remoteUid),
|
|
||||||
view: document.getElementById(`video-${remoteUid}`),
|
|
||||||
channelId: info.channelId,
|
|
||||||
})
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
|
||||||
if (info.channelId === state.channelId) {
|
|
||||||
if (String(remoteUid).length === 9) {
|
|
||||||
setIsShare(null)
|
|
||||||
renderVideo()
|
|
||||||
}
|
|
||||||
await agora.setupRemoteVideo({
|
|
||||||
uid: Number(remoteUid),
|
|
||||||
view: null,
|
|
||||||
channelId: info.channelId,
|
|
||||||
});
|
|
||||||
setCurrentVideoId((res: any) => {
|
|
||||||
if (Number(res) === remoteUid) {
|
|
||||||
getShowUser();
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onAudioVolumeIndication: async (speakers: any) => {
|
|
||||||
speakers.forEach((item: any) => {
|
|
||||||
let dom = document.getElementById(`micr-${item.uid ? item.uid : userInfo.uid}`);
|
|
||||||
if (dom) {
|
|
||||||
const percentage = (item.volume / 255) * 100
|
|
||||||
dom.style.width = `${percentage}%`
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if (state.enableCamera) {
|
|
||||||
agora.startCameraCapture()
|
|
||||||
}
|
|
||||||
agora.setJoinChannel({
|
|
||||||
channelId: state.channelId,
|
|
||||||
uid: userInfo.uid,
|
|
||||||
screenShareId: userInfo.screenShareId,
|
|
||||||
token: state.token,
|
|
||||||
tokenA: state.tokenA,
|
|
||||||
})
|
|
||||||
storage.setItem('noViewChatList', 0)
|
storage.setItem('noViewChatList', 0)
|
||||||
window.addEventListener('customStorageChange', handleCustomStorageChange);
|
window.addEventListener('customStorageChange', handleCustomStorageChange);
|
||||||
window.addEventListener('online', handleNetworkChange);
|
window.addEventListener('online', handleNetworkChange);
|
||||||
|
|
@ -542,6 +471,81 @@ const Meeting: React.FC = () => {
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [isClicked]);
|
}, [isClicked]);
|
||||||
|
|
||||||
|
// 声网初始化
|
||||||
|
const agoraInit = async () => {
|
||||||
|
await agora.init(true)
|
||||||
|
agora.registerEventHandler({
|
||||||
|
onJoinChannelSuccess: async (info: any, _elapsed: any) => {
|
||||||
|
if (info.channelId === state.channelId) {
|
||||||
|
if (String(info.localUid).length !== 9) {
|
||||||
|
await getJoin(state.enableMicr, state.enableCamera)
|
||||||
|
setTimeout(async () => {
|
||||||
|
await agora.setupLocalVideo({
|
||||||
|
uid: Number(info.localUid),
|
||||||
|
view: document.getElementById(`video-${info.localUid}`),
|
||||||
|
channelId: info.channelId,
|
||||||
|
sourceType: VideoSourceType.VideoSourceCameraPrimary,
|
||||||
|
})
|
||||||
|
getShowUser();
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
||||||
|
if (info.channelId === state.channelId) {
|
||||||
|
if (String(remoteUid).length === 9) {
|
||||||
|
setIsShare(remoteUid)
|
||||||
|
} else {
|
||||||
|
setTimeout(async () => {
|
||||||
|
await agora.setupRemoteVideoJoin({
|
||||||
|
uid: Number(remoteUid),
|
||||||
|
view: document.getElementById(`video-${remoteUid}`),
|
||||||
|
channelId: info.channelId,
|
||||||
|
})
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
||||||
|
if (info.channelId === state.channelId) {
|
||||||
|
if (String(remoteUid).length === 9) {
|
||||||
|
setIsShare(null)
|
||||||
|
renderVideo()
|
||||||
|
}
|
||||||
|
await agora.setupRemoteVideo({
|
||||||
|
uid: Number(remoteUid),
|
||||||
|
view: null,
|
||||||
|
channelId: info.channelId,
|
||||||
|
});
|
||||||
|
setCurrentVideoId((res: any) => {
|
||||||
|
if (Number(res) === remoteUid) {
|
||||||
|
getShowUser();
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onAudioVolumeIndication: async (speakers: any) => {
|
||||||
|
speakers.forEach((item: any) => {
|
||||||
|
let dom = document.getElementById(`micr-${item.uid ? item.uid : userInfo.uid}`);
|
||||||
|
if (dom) {
|
||||||
|
const percentage = (item.volume / 255) * 100
|
||||||
|
dom.style.width = `${percentage}%`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (state.enableCamera) {
|
||||||
|
agora.startCameraCapture()
|
||||||
|
}
|
||||||
|
agora.setJoinChannel({
|
||||||
|
channelId: state.channelId,
|
||||||
|
uid: userInfo.uid,
|
||||||
|
screenShareId: userInfo.screenShareId,
|
||||||
|
token: state.token,
|
||||||
|
tokenA: state.tokenA,
|
||||||
|
})
|
||||||
|
}
|
||||||
// 状态更新
|
// 状态更新
|
||||||
const changeAgoraDevice = () => {
|
const changeAgoraDevice = () => {
|
||||||
setRoomUserList((res: any) => {
|
setRoomUserList((res: any) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue