全员观看-活跃用户

This commit is contained in:
yj 2025-02-24 16:38:47 +08:00
parent 9c4e9cb918
commit 3b61578baa
1 changed files with 35 additions and 4 deletions

View File

@ -10,6 +10,7 @@ const computedBehavior = require('miniprogram-computed').behavior;
let reconnectTime = "" as any; let reconnectTime = "" as any;
let refreshTime = "" as any; let refreshTime = "" as any;
let isAutoApplySpeakTime = "" as any; let isAutoApplySpeakTime = "" as any;
let isSpeakTime = "" as any;
Page({ Page({
behaviors: [computedBehavior], behaviors: [computedBehavior],
data: { data: {
@ -114,7 +115,8 @@ Page({
userNumer: roomUserList.filter((item: any) => item.isRoom).length, userNumer: roomUserList.filter((item: any) => item.isRoom).length,
audioList: roomUserList.map(item => { audioList: roomUserList.map(item => {
return { return {
volume: 0, volume: item.volume || '0%',
volumeNumber: item.volumeNumber || 0,
uid: item.uid, uid: item.uid,
} }
}) })
@ -282,6 +284,25 @@ Page({
} else { } else {
this.reconnecFun() this.reconnecFun()
} }
isSpeakTime = setInterval(() => {
function getMaxObject(arr) {
let maxObject = arr[0];
for (let i = 1; i < arr.length; i++) {
if (arr[i].volumeNumber > maxObject.volumeNumber) {
maxObject = arr[i];
}
}
return maxObject;
}
const isShare = this.data.roomUserList.find(item => item.shareSrc)
const item = getMaxObject(this.data.audioList)
const user = this.data.roomUserList.find(row => item.uid === row.uid)
if (this.data.currentUid !== item.uid && !isShare && (user && user.isRoom)) {
this.setData({
currentUid: item.uid
})
}
}, 3000)
}, },
// 隐藏 // 隐藏
onHide() { onHide() {
@ -377,6 +398,10 @@ Page({
clearTimeout(isAutoApplySpeakTime) clearTimeout(isAutoApplySpeakTime)
isAutoApplySpeakTime = '' isAutoApplySpeakTime = ''
} }
if (isSpeakTime) {
clearTimeout(isSpeakTime)
isSpeakTime = ''
}
}, },
// 显示聊天输入框 // 显示聊天输入框
showInputPopup() { showInputPopup() {
@ -1023,6 +1048,7 @@ Page({
const item = audioListTemp.find(row => row.uid == uid) const item = audioListTemp.find(row => row.uid == uid)
if (item) { if (item) {
item.volume = Math.floor(percentage) + '%' item.volume = Math.floor(percentage) + '%'
item.volumeNumber = Math.floor(percentage)
} }
this.setData({ this.setData({
audioList: audioListTemp, audioList: audioListTemp,
@ -1032,9 +1058,14 @@ Page({
// 切换视频 // 切换视频
clickChangeVideo(e) { clickChangeVideo(e) {
const { item } = e.currentTarget.dataset; const { item } = e.currentTarget.dataset;
this.setData({ const isShare = this.data.roomUserList.find(item => item.shareSrc)
currentUid: item.uid if (isShare) {
}) this.message(`正在进行屏幕共享,不允许切换画面。`).error()
} else {
this.setData({
currentUid: item.uid
})
}
}, },
// 悬浮提示 // 悬浮提示
message(content: string) { message(content: string) {