|
|
@@ -474,9 +474,6 @@ export const ClassroomPage = () => {
|
|
|
listenMessageEvents();
|
|
|
listenRtcEvents();
|
|
|
|
|
|
- // 设置本地预览配置
|
|
|
- aliRtcEngine.current.setLocalViewConfig('localPreviewer', AliRtcVideoTrack.AliRtcVideoTrackCamera);
|
|
|
-
|
|
|
setIsJoinedClass(true);
|
|
|
setErrorMessage('');
|
|
|
showToast('success', '加入课堂成功');
|
|
|
@@ -522,21 +519,6 @@ export const ClassroomPage = () => {
|
|
|
if (!imMessageManager.current || !classId || role !== Role.Teacher) return;
|
|
|
|
|
|
try {
|
|
|
- // 确保RTC连接已建立
|
|
|
- if (!aliRtcEngine.current) {
|
|
|
- throw new Error('RTC连接未建立');
|
|
|
- }
|
|
|
-
|
|
|
- // 开启老师视频
|
|
|
- try {
|
|
|
- aliRtcEngine.current!.setLocalViewConfig('localPreviewer', AliRtcVideoTrack.AliRtcVideoTrackCamera);
|
|
|
- await aliRtcEngine.current.startPreview();
|
|
|
- console.log('老师视频已开启');
|
|
|
- } catch (err) {
|
|
|
- console.error('开启老师视频失败:', err);
|
|
|
- showToast('error', '开启视频失败');
|
|
|
- throw err;
|
|
|
- }
|
|
|
|
|
|
// 发送开始上课消息
|
|
|
await imMessageManager.current.sendGroupMessage({
|
|
|
@@ -674,7 +656,7 @@ export const ClassroomPage = () => {
|
|
|
await aliRtcEngine.current.leaveChannel();
|
|
|
showToast('info', '摄像头已关闭并退出RTC频道');
|
|
|
} else {
|
|
|
- // 加入RTC频道并开启摄像头
|
|
|
+ // 加入RTC频道并配置本地预览
|
|
|
const timestamp = Math.floor(Date.now() / 1000) + 3600 * 3;
|
|
|
const token = await generateToken(RTC_APP_ID, RTC_APP_KEY, classId, userId, timestamp);
|
|
|
await aliRtcEngine.current.joinChannel(
|
|
|
@@ -687,6 +669,8 @@ export const ClassroomPage = () => {
|
|
|
},
|
|
|
userId
|
|
|
);
|
|
|
+ // 统一设置本地预览配置
|
|
|
+ aliRtcEngine.current.setLocalViewConfig('localPreviewer', AliRtcVideoTrack.AliRtcVideoTrackCamera);
|
|
|
await aliRtcEngine.current.startPreview();
|
|
|
showToast('info', '已加入RTC频道并开启摄像头');
|
|
|
}
|