加入时默认静音
This commit is contained in:
@@ -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'
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user