|
|
@@ -723,38 +723,28 @@ export const ClassroomPage = () => {
|
|
|
// showToast('info', '已离开RTC频道');
|
|
|
};
|
|
|
|
|
|
- // 开启摄像头预览
|
|
|
- const startCameraPreview = async () => {
|
|
|
- if (!aliRtcEngine.current) return;
|
|
|
-
|
|
|
- await leaveRtcChannel()
|
|
|
- await joinRtcChannel(classId, {
|
|
|
- publishVideo:true
|
|
|
- })
|
|
|
- aliRtcEngine.current.setLocalViewConfig('localPreviewer', AliRtcVideoTrack.AliRtcVideoTrackCamera);
|
|
|
- await aliRtcEngine.current.startPreview();
|
|
|
- // showToast('info', '摄像头已开启');
|
|
|
- };
|
|
|
|
|
|
- // 关闭摄像头预览
|
|
|
- const stopCameraPreview = async () => {
|
|
|
- if (!aliRtcEngine.current) return;
|
|
|
-
|
|
|
- await leaveRtcChannel()
|
|
|
- await joinRtcChannel(classId, {
|
|
|
- publishVideo: false
|
|
|
- })
|
|
|
- await aliRtcEngine.current.stopPreview();
|
|
|
- // showToast('info', '摄像头已关闭');
|
|
|
- };
|
|
|
|
|
|
// 切换摄像头状态
|
|
|
const toggleCamera = async () => {
|
|
|
try {
|
|
|
if (isCameraOn) {
|
|
|
- await stopCameraPreview();
|
|
|
+ await leaveRtcChannel();
|
|
|
+ await joinRtcChannel(classId, {
|
|
|
+ publishVideo: false,
|
|
|
+ publishAudio: isAudioOn,
|
|
|
+ publishScreen: isScreenSharing
|
|
|
+ });
|
|
|
+ await aliRtcEngine.current?.stopPreview();
|
|
|
} else {
|
|
|
- await startCameraPreview();
|
|
|
+ await leaveRtcChannel();
|
|
|
+ await joinRtcChannel(classId, {
|
|
|
+ publishVideo: true,
|
|
|
+ publishAudio: isAudioOn,
|
|
|
+ publishScreen: isScreenSharing
|
|
|
+ });
|
|
|
+ aliRtcEngine.current?.setLocalViewConfig('localPreviewer', AliRtcVideoTrack.AliRtcVideoTrackCamera);
|
|
|
+ await aliRtcEngine.current?.startPreview();
|
|
|
}
|
|
|
setIsCameraOn(!isCameraOn);
|
|
|
} catch (err) {
|