From 85cfd2e39f075e0d9a634bc7f25c1641587a5a4c Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Tue, 26 Nov 2024 09:39:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8A=82=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/meeting/index.ts | 20 +++++++++++++++++++- pages/meeting/index.wxml | 8 ++++---- utils/agora.ts | 10 +++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/pages/meeting/index.ts b/pages/meeting/index.ts index 156082f..b46d151 100644 --- a/pages/meeting/index.ts +++ b/pages/meeting/index.ts @@ -105,6 +105,7 @@ Page({ } }) }) + this.scroll() }, 'footerList.**': function (footerList) { const footerListTemplate = [...footerList]; @@ -389,7 +390,7 @@ Page({ if (res.code === 200 && res.data) { const currentUser = this.data.roomUserList.find(row => row.uid == res.data || row.screenShareId == res.data) this.setData({ - currentUid: res.data, + currentUid: currentUser.uid, currentUser, }) } @@ -789,4 +790,21 @@ Page({ }) } }, + scroll() { + const query = wx.createSelectorQuery().in(this); + query.select('#meeting-content-smallvideo').boundingClientRect() + query.selectAll('.meeting-content-smallvideo-box').boundingClientRect() + query.exec((res) => { + const listItemRects = res[1]; + listItemRects.forEach(rect => { + if (rect.top < res[0].height && rect.top + rect.height > 0) { + agora.unmute(Number(rect.dataset.item.uid), 'video') + } else { + if (rect.dataset.item.uid != this.data.currentUid) { + agora.mute(Number(rect.dataset.item.uid), 'video') + } + } + }); + }) + }, }) \ No newline at end of file diff --git a/pages/meeting/index.wxml b/pages/meeting/index.wxml index c9cd0a0..4c15264 100644 --- a/pages/meeting/index.wxml +++ b/pages/meeting/index.wxml @@ -29,10 +29,10 @@ {{currentUser.userName}} - + - - + + {{item.avatarName}} @@ -59,7 +59,7 @@ - + ` diff --git a/utils/agora.ts b/utils/agora.ts index d92f25b..8bf5262 100644 --- a/utils/agora.ts +++ b/utils/agora.ts @@ -74,5 +74,13 @@ export const agora = { // 设置订阅的视频流类型。 0 大流 1 小流 setRemoteVideoStreamType: async (uid: number, streamType: 0 | 1) => { await client.setRemoteVideoStreamType(uid, streamType) - } + }, + // 停止接收远端用户的音视频流。 + mute: async (uid: number, target: string) => { + await client.mute(uid, target) + }, + // 恢复接收远端用户的音视频流。 + unmute: async (uid: number, target: string) => { + await client.unmute(uid, target) + }, } \ No newline at end of file