视频显示优化

This commit is contained in:
yj 2024-08-21 11:10:21 +08:00
parent a4b24252d6
commit 85566f4a91
1 changed files with 31 additions and 3 deletions

View File

@ -177,10 +177,15 @@ const Meeting: React.FC = () => {
}, 1000); }, 1000);
} }
}, },
onUserOffline: async (_info: any, remoteUid: any, _reason: any) => { onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
if (String(remoteUid).length === 9) { if (String(remoteUid).length === 9) {
setIsShare(null) setIsShare(null)
} }
await agora.setupRemoteVideo({
uid: Number(remoteUid),
view: null,
channelId: info.channelId,
});
setCurrentVideoId((res: any) => { setCurrentVideoId((res: any) => {
if (Number(res) === remoteUid) { if (Number(res) === remoteUid) {
getShowUser(); getShowUser();
@ -439,8 +444,27 @@ const Meeting: React.FC = () => {
return res return res
}) })
} }
// 刷新视图
const RefreshVideoView = async (list: any): Promise<void> => {
list.forEach(async (item: any) => {
if (item.uid === userInfo.uid) {
await agora.setupLocalVideo({
uid: Number(item.uid),
view: document.getElementById(`video-${item.uid}`),
channelId: state.channelId,
sourceType: VideoSourceType.VideoSourceCameraPrimary,
})
} else {
await agora.setupRemoteVideo({
uid: Number(item.uid),
view: document.getElementById(`video-${item.uid}`),
channelId: state.channelId,
})
}
});
}
// 替换数据 // 替换数据
const setAllUserListData = (key: string, item: any, callBack?: Function): void => { const setAllUserListData = async (key: string, item: any, callBack?: Function): Promise<void> => {
switch (key) { switch (key) {
case 'OperMicr': case 'OperMicr':
case 'OperCamera': case 'OperCamera':
@ -465,6 +489,9 @@ const Meeting: React.FC = () => {
setRoomUserList((res: any) => { setRoomUserList((res: any) => {
let userItemIndex = res.findIndex((row: any) => row.uid === item.uid) let userItemIndex = res.findIndex((row: any) => row.uid === item.uid)
res.splice(userItemIndex, 1) res.splice(userItemIndex, 1)
setTimeout(() => {
RefreshVideoView(res)
}, 1000);
return res return res
}) })
break; break;
@ -1059,9 +1086,10 @@ const Meeting: React.FC = () => {
<div className={styles.meetingContent}> <div className={styles.meetingContent}>
<div className={styles.meetingContentBody}> <div className={styles.meetingContentBody}>
<div className={`${styles.meetingContentBodyLeft} drag`}> <div className={`${styles.meetingContentBodyLeft} drag`}>
<div className={getMeetingContentBodyLeftModeClass()} > <div className={getMeetingContentBodyLeftModeClass()} id='videoView'>
{roomUserList.map((item: any, index: number) => { {roomUserList.map((item: any, index: number) => {
return (index <= 19 ? <div return (index <= 19 ? <div
id={item.uid}
className={`${styles.meetingContentSwiperCard}`} className={`${styles.meetingContentSwiperCard}`}
key={index} key={index}
onClick={() => { onClick={() => {