优化接流限制
This commit is contained in:
parent
adf86ef62e
commit
5fabfd7308
|
|
@ -174,6 +174,7 @@ const Meeting: React.FC = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const [isVideoFullScreen, setIsVideoFullScreen] = useState<boolean>(false)
|
const [isVideoFullScreen, setIsVideoFullScreen] = useState<boolean>(false)
|
||||||
|
const [observer, setObserver] = useState<IntersectionObserver>()
|
||||||
let userInfo = JSON.parse(storage.getItem('user') as string)
|
let userInfo = JSON.parse(storage.getItem('user') as string)
|
||||||
const msgTips = '您不是管理员或发言人,无法开启此功能!'
|
const msgTips = '您不是管理员或发言人,无法开启此功能!'
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -583,6 +584,33 @@ const Meeting: React.FC = () => {
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [isClicked]);
|
}, [isClicked]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const elements = document.querySelectorAll('.intersectionObserver-view');
|
||||||
|
if (elements.length && currentVideoId) {
|
||||||
|
elements.forEach(element => {
|
||||||
|
observer?.unobserve(element);
|
||||||
|
});
|
||||||
|
const observerObject = new IntersectionObserver(async (entries: IntersectionObserverEntry[], _observer: IntersectionObserver) => {
|
||||||
|
entries.forEach(async (entry) => {
|
||||||
|
if (entry.target.id !== user.uid) {
|
||||||
|
await agora.muteRemoteVideoStreamEx(Number(entry.target.id), !entry.isIntersecting)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await agora.muteRemoteVideoStreamEx(Number(currentVideoId), false)
|
||||||
|
}, { threshold: 0.1, root: document.getElementById('videoView') });
|
||||||
|
setObserver(observerObject)
|
||||||
|
elements.forEach(element => {
|
||||||
|
observerObject.observe(element);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
elements.forEach(element => {
|
||||||
|
observer?.unobserve(element);
|
||||||
|
});
|
||||||
|
observer?.disconnect();
|
||||||
|
}
|
||||||
|
}, [roomUserList, currentVideoId]);
|
||||||
|
|
||||||
// 声网初始化
|
// 声网初始化
|
||||||
const agoraInit = async () => {
|
const agoraInit = async () => {
|
||||||
await agora.init(true)
|
await agora.init(true)
|
||||||
|
|
@ -1510,7 +1538,7 @@ const Meeting: React.FC = () => {
|
||||||
{roomUserList.map((item: any, index: number) => {
|
{roomUserList.map((item: any, index: number) => {
|
||||||
return (index <= 19 && item.isRoom && item.isAdmin ? <div
|
return (index <= 19 && item.isRoom && item.isAdmin ? <div
|
||||||
id={item.uid}
|
id={item.uid}
|
||||||
className={`${styles.meetingContentSwiperCard}`}
|
className={`${styles.meetingContentSwiperCard} intersectionObserver-view`}
|
||||||
key={index}
|
key={index}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (String(isShare) === item.screenShareId) {
|
if (String(isShare) === item.screenShareId) {
|
||||||
|
|
|
||||||
|
|
@ -295,6 +295,10 @@ export const agora = {
|
||||||
await agora.stopCameraCapture();
|
await agora.stopCameraCapture();
|
||||||
await rtcEngine.leaveChannelEx({ channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) })
|
await rtcEngine.leaveChannelEx({ channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) })
|
||||||
},
|
},
|
||||||
|
// 停止/恢复接收指定的视频流。
|
||||||
|
muteRemoteVideoStreamEx: async (uid: number, mute: boolean) => {
|
||||||
|
await rtcEngine.muteRemoteVideoStreamEx(uid, mute, { channelId: option.channelId, localUid: Number(option.uid) })
|
||||||
|
},
|
||||||
// 取消或恢复订阅指定远端用户的音频流
|
// 取消或恢复订阅指定远端用户的音频流
|
||||||
muteRemoteVideoStream: async (uid: number, mute: boolean) => {
|
muteRemoteVideoStream: async (uid: number, mute: boolean) => {
|
||||||
rtcEngine.muteRemoteVideoStream(uid, mute)
|
rtcEngine.muteRemoteVideoStream(uid, mute)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue