From b92f4336133e8529ed6d932e2591a532e10dd8e8 Mon Sep 17 00:00:00 2001 From: stary <834207172@qq.COM> Date: Sat, 25 Apr 2026 17:01:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=97=B6=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E9=9D=99=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WebApp/client/public/onebyone/store.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/WebApp/client/public/onebyone/store.js b/WebApp/client/public/onebyone/store.js index 84ccf13..b995968 100644 --- a/WebApp/client/public/onebyone/store.js +++ b/WebApp/client/public/onebyone/store.js @@ -347,6 +347,18 @@ class CallStateManager { this.state.session.status = 'ongoing'; this.notify({ type: 'CALL_STATUS_CHANGE', status: 'ongoing' }); + // 参与者加入时默认静音:禁用音频轨道并更新状态 + if (this.role === 'participant') { + if (this.state.localStream) { + this.state.localStream.getAudioTracks().forEach(track => { + track.enabled = false; + }); + } + this.state.session.localUser.mediaState.audio = false; + this.notify({ type: 'LOCAL_MEDIA_CHANGE', mediaType: 'audio', value: false }); + console.log('Participant joined with audio muted by default'); + } + // 连接建立后发送本地用户信息 this.sendMessage('user-info', { id: this.state.session.localUser.id, @@ -354,6 +366,9 @@ class CallStateManager { avatar: this.state.session.localUser.avatar }); + // 发送当前媒体状态,确保远端收到正确的初始状态 + this.emitMediaStateChange(); + if (this.state.localStream) { // const tracks = this.state.localStream.getTracks(); // for (const track of tracks) { @@ -381,7 +396,7 @@ class CallStateManager { id: '', name: '参与者', avatar: '/images/p2.png', - mediaState: { audio: false, video: false, isSpeaking: false }, + mediaState: { audio: false, video: true, isSpeaking: false }, status: 'online' }; } @@ -449,7 +464,7 @@ class CallStateManager { id: '', name: '参与者', avatar: '/images/p2.png', - mediaState: { audio: false, video: false, isSpeaking: false }, + mediaState: { audio: false, video: true, isSpeaking: false }, status: 'online' }; this.notify({ type: 'PARTICIPANTS_UPDATE', participants: this.state.participants }); @@ -546,7 +561,7 @@ class CallStateManager { id: '', name: '参与者', avatar: '/images/p2.png', - mediaState: { audio: false, video: false, isSpeaking: false }, + mediaState: { audio: false, video: true, isSpeaking: false }, status: 'online' }; }