完成
This commit is contained in:
@@ -480,13 +480,30 @@ class CallStateManager {
|
||||
}
|
||||
|
||||
// 通知UI远程流已更新
|
||||
this.notify({
|
||||
type: 'REMOTE_STREAM_OBTAINED',
|
||||
stream: targetStream,
|
||||
connectionId: trackParticipantId,
|
||||
isHost: isHost
|
||||
});
|
||||
console.log('Notified UI about remote stream update');
|
||||
// 关键优化:如果是音频轨道先到达且流中尚无视频轨道,
|
||||
// 延迟通知UI等待视频轨道到达,避免音频先触发的UI更新导致黑屏
|
||||
const notifyStreamUpdate = () => {
|
||||
this.notify({
|
||||
type: 'REMOTE_STREAM_OBTAINED',
|
||||
stream: targetStream,
|
||||
connectionId: trackParticipantId,
|
||||
isHost: isHost
|
||||
});
|
||||
console.log('Notified UI about remote stream update');
|
||||
};
|
||||
|
||||
if (data.track.kind === 'audio' && targetStream.getVideoTracks().length === 0) {
|
||||
// 音频先到,视频尚未到达:延迟200ms通知,给视频轨道到达的机会
|
||||
console.log('Audio track arrived first, delaying stream notification for video track...');
|
||||
setTimeout(() => {
|
||||
const nowHasVideo = targetStream.getVideoTracks().length > 0;
|
||||
console.log(`After delay, stream has video: ${nowHasVideo}`);
|
||||
notifyStreamUpdate();
|
||||
}, 200);
|
||||
} else {
|
||||
// 视频轨道到达,或音频视频同时存在:立即通知
|
||||
notifyStreamUpdate();
|
||||
}
|
||||
// 只有当收到远程流时才更新远程用户状态为在线
|
||||
if (this.state.session.remoteUser.status !== 'online') {
|
||||
this.updateRemoteUserStatus('online');
|
||||
|
||||
Reference in New Issue
Block a user