|
|
@@ -780,24 +780,37 @@ export const ClassroomPage = () => {
|
|
|
|
|
|
// 切换摄像头状态
|
|
|
const toggleCamera = async () => {
|
|
|
+ if(!aliRtcEngine.current?.isInCall){
|
|
|
+ showToast('error', '先加入课堂');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
if (isCameraOn) {
|
|
|
- await leaveRtcChannel();
|
|
|
- await joinRtcChannel(classId, {
|
|
|
- publishVideo: false,
|
|
|
- publishAudio: isAudioOn,
|
|
|
- publishScreen: isScreenSharing
|
|
|
- });
|
|
|
+ // await leaveRtcChannel();
|
|
|
+ // await joinRtcChannel(classId, {
|
|
|
+ // publishVideo: false,
|
|
|
+ // publishAudio: isAudioOn,
|
|
|
+ // publishScreen: isScreenSharing
|
|
|
+ // });
|
|
|
await aliRtcEngine.current?.stopPreview();
|
|
|
+ await aliRtcEngine.current?.enableLocalVideo(false)
|
|
|
+ await aliRtcEngine.current?.publishLocalVideoStream(false)
|
|
|
} else {
|
|
|
- await leaveRtcChannel();
|
|
|
- await joinRtcChannel(classId, {
|
|
|
- publishVideo: true,
|
|
|
- publishAudio: isAudioOn,
|
|
|
- publishScreen: isScreenSharing
|
|
|
- });
|
|
|
+ // await leaveRtcChannel();
|
|
|
+ // await joinRtcChannel(classId, {
|
|
|
+ // publishVideo: true,
|
|
|
+ // publishAudio: isAudioOn,
|
|
|
+ // publishScreen: isScreenSharing
|
|
|
+ // });
|
|
|
await aliRtcEngine.current?.setLocalViewConfig('localPreviewer', AliRtcVideoTrack.AliRtcVideoTrackCamera);
|
|
|
+ await aliRtcEngine.current?.enableLocalVideo(true)
|
|
|
await aliRtcEngine.current?.startPreview();
|
|
|
+ setTimeout(()=>{
|
|
|
+ showToast('info', '开始推流');
|
|
|
+ aliRtcEngine.current?.publishLocalVideoStream(true)
|
|
|
+ aliRtcEngine.current?.startAndPublishDefaultDevices()
|
|
|
+ },1000 * 5)
|
|
|
}
|
|
|
setIsCameraOn(!isCameraOn);
|
|
|
} catch (err) {
|
|
|
@@ -824,23 +837,31 @@ export const ClassroomPage = () => {
|
|
|
|
|
|
// 切换屏幕分享状态
|
|
|
const toggleScreenShare = async () => {
|
|
|
+ if(!aliRtcEngine.current?.isInCall){
|
|
|
+ showToast('error', '先加入课堂');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
if (isScreenSharing) {
|
|
|
- await leaveRtcChannel();
|
|
|
- await joinRtcChannel(classId, {
|
|
|
- publishVideo: isCameraOn,
|
|
|
- publishAudio: isAudioOn,
|
|
|
- publishScreen: false
|
|
|
- });
|
|
|
- await aliRtcEngine.current?.stopPreviewScreen();
|
|
|
+ // await leaveRtcChannel();
|
|
|
+ // await joinRtcChannel(classId, {
|
|
|
+ // publishVideo: isCameraOn,
|
|
|
+ // publishAudio: isAudioOn,
|
|
|
+ // publishScreen: false
|
|
|
+ // });
|
|
|
+ // await aliRtcEngine.current?.stopPreviewScreen();
|
|
|
+ await aliRtcEngine.current?.publishLocalScreenShareStream(false)
|
|
|
+ await aliRtcEngine.current?.stopScreenShare()
|
|
|
} else {
|
|
|
- await leaveRtcChannel();
|
|
|
- // 设置屏幕分享预览视图
|
|
|
- await joinRtcChannel(classId, {
|
|
|
- publishVideo: isCameraOn,
|
|
|
- publishAudio: isAudioOn,
|
|
|
- publishScreen: true
|
|
|
- });
|
|
|
+ // await leaveRtcChannel();
|
|
|
+ // // 设置屏幕分享预览视图
|
|
|
+ // await joinRtcChannel(classId, {
|
|
|
+ // publishVideo: isCameraOn,
|
|
|
+ // publishAudio: isAudioOn,
|
|
|
+ // publishScreen: true
|
|
|
+ // });
|
|
|
+ await aliRtcEngine.current?.publishLocalScreenShareStream(true)
|
|
|
await aliRtcEngine.current?.setLocalViewConfig(
|
|
|
'screenPreviewer',
|
|
|
AliRtcVideoTrack.AliRtcVideoTrackScreen
|
|
|
@@ -850,7 +871,8 @@ export const ClassroomPage = () => {
|
|
|
// videoTrack: undefined, // 使用默认视频轨道
|
|
|
// audioTrack: undefined // 使用默认音频轨道
|
|
|
// });
|
|
|
- await aliRtcEngine.current?.startPreviewScreen()
|
|
|
+ // await aliRtcEngine.current?.startPreviewScreen()
|
|
|
+ // await aliRtcEngine.current?.startScreenShare()
|
|
|
}
|
|
|
setIsScreenSharing(!isScreenSharing);
|
|
|
} catch (err) {
|