|
|
|
@ -320,19 +320,71 @@ class _VideoCallPageState extends State<VideoCallPage> { |
|
|
|
final callSession = _callController.currentCall.value; |
|
|
|
final isVideoCall = callSession != null && callSession.callType == CallType.video; |
|
|
|
|
|
|
|
// 如果是视频通话,显示本地视频视图 |
|
|
|
if (isVideoCall && _localVideoViewController != null) { |
|
|
|
Get.log('显示本地视频视图$_localVideoViewController'); |
|
|
|
return SizedBox( |
|
|
|
width: double.infinity, |
|
|
|
height: 1.sh, |
|
|
|
child: AgoraVideoView( |
|
|
|
controller: _localVideoViewController!, |
|
|
|
), |
|
|
|
); |
|
|
|
// 使用 Obx 监听远端用户 UID 的变化 |
|
|
|
if (isVideoCall) { |
|
|
|
return Obx(() { |
|
|
|
// 同时监听 CallController.remoteUid 和 RTCManager.remoteUsersNotifier |
|
|
|
var remoteUid = _callController.remoteUid.value; |
|
|
|
final remoteUsers = _rtcManager.remoteUsersNotifier.value; // 触发 Obx 监听 |
|
|
|
|
|
|
|
print('📞 [VideoCallPage] Obx 重建,CallController.remoteUid: ${_callController.remoteUid.value}, remoteUsers: $remoteUsers, isVideoCall: $isVideoCall'); |
|
|
|
|
|
|
|
// 如果 remoteUid 为空,尝试从 RTCManager 的远端用户列表中获取 |
|
|
|
if (remoteUid == null && remoteUsers.isNotEmpty) { |
|
|
|
remoteUid = remoteUsers.first; |
|
|
|
// 同步到 CallController |
|
|
|
_callController.remoteUid.value = remoteUid; |
|
|
|
print('📞 [VideoCallPage] 从 RTCManager.remoteUsersNotifier 获取到 remoteUid: $remoteUid'); |
|
|
|
} |
|
|
|
|
|
|
|
// 如果远端用户已加入,显示远端视频视图(对方画面) |
|
|
|
if (remoteUid != null) { |
|
|
|
final engine = _rtcManager.engine; |
|
|
|
print('📞 [VideoCallPage] remoteUid 不为 null: $remoteUid, engine: ${engine != null}'); |
|
|
|
if (engine != null) { |
|
|
|
print('📞 [VideoCallPage] 显示远端视频视图,UID:$remoteUid'); |
|
|
|
final remoteVideoViewController = VideoViewController( |
|
|
|
rtcEngine: engine, |
|
|
|
canvas: VideoCanvas(uid: remoteUid), |
|
|
|
); |
|
|
|
return SizedBox( |
|
|
|
width: double.infinity, |
|
|
|
height: 1.sh, |
|
|
|
child: AgoraVideoView( |
|
|
|
controller: remoteVideoViewController, |
|
|
|
), |
|
|
|
); |
|
|
|
} else { |
|
|
|
print('⚠️ [VideoCallPage] engine 为 null,无法显示远端视频'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
print('⚠️ [VideoCallPage] remoteUid 为 null,无法显示远端视频'); |
|
|
|
} |
|
|
|
|
|
|
|
// 如果没有远端视频,显示本地视频视图(自己的画面) |
|
|
|
if (_localVideoViewController != null) { |
|
|
|
print('📞 [VideoCallPage] 显示本地视频视图'); |
|
|
|
return SizedBox( |
|
|
|
width: double.infinity, |
|
|
|
height: 1.sh, |
|
|
|
child: AgoraVideoView( |
|
|
|
controller: _localVideoViewController!, |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 如果本地视频也没有,显示模糊的头像背景 |
|
|
|
print('📞 [VideoCallPage] 显示头像背景'); |
|
|
|
return _buildAvatarBackground(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 否则显示模糊的头像背景 |
|
|
|
// 非视频通话,显示模糊的头像背景 |
|
|
|
return _buildAvatarBackground(); |
|
|
|
} |
|
|
|
|
|
|
|
/// 构建头像背景 |
|
|
|
Widget _buildAvatarBackground() { |
|
|
|
return SizedBox( |
|
|
|
width: double.infinity, |
|
|
|
height: 1.sh, |
|
|
|
|