|
@@ -13,6 +13,8 @@ import { showConfirmDialog, showSuccessToast, showFailToast } from 'vant';
|
|
|
let offsetTimer: NodeJS.Timeout
|
|
|
let offsetTime = $ref<number>(0)
|
|
|
|
|
|
+const RTC_USE = window.RTC_USE
|
|
|
+
|
|
|
const emits = defineEmits<{
|
|
|
(event: 'update-info', info: Partial<type_dyaw_xlfw_zxhd_log>, isUpdate?: boolean): void;
|
|
|
}>()
|
|
@@ -215,6 +217,7 @@ type TRtcOptions = {
|
|
|
let rtcOptions: TRtcOptions;
|
|
|
|
|
|
function handleSwitchUse(v: boolean) {
|
|
|
+ if (!RTC_USE) return
|
|
|
// console.info('[in handleSwitchUse] start ');
|
|
|
try {
|
|
|
audioInUse = v
|
|
@@ -232,6 +235,7 @@ function handleSwitchUse(v: boolean) {
|
|
|
}
|
|
|
|
|
|
function initRtcClient() {
|
|
|
+ if (!RTC_USE) return
|
|
|
console.info('[in initRtcClient] start')
|
|
|
|
|
|
if (rtcInstance.client) {
|
|
@@ -253,6 +257,7 @@ function initRtcClient() {
|
|
|
}
|
|
|
|
|
|
async function getRtcOption() {
|
|
|
+ if (!RTC_USE) return
|
|
|
console.info('[in getRtcOption] start')
|
|
|
try {
|
|
|
await request({
|
|
@@ -309,23 +314,24 @@ async function handleAudioChatStart() {
|
|
|
}, 5000)
|
|
|
return
|
|
|
};
|
|
|
-
|
|
|
- console.info('验证相关权限')
|
|
|
- // 手机版跳过验证
|
|
|
- try {
|
|
|
- console.info('验证麦克风权限')
|
|
|
- const microInfo = await AgoraRTC.getMicrophones()
|
|
|
- console.info('麦克风权限验证结束 : ', microInfo)
|
|
|
- if (mode === 'video') {
|
|
|
- console.info('验证摄像头权限')
|
|
|
- const camerasInfo = await AgoraRTC.getCameras()
|
|
|
- console.info('摄像头权限验证结束 : ', camerasInfo)
|
|
|
+ if (RTC_USE) {
|
|
|
+
|
|
|
+ console.info('验证相关权限')
|
|
|
+ // 手机版跳过验证
|
|
|
+ try {
|
|
|
+ console.info('验证麦克风权限')
|
|
|
+ const microInfo = await AgoraRTC.getMicrophones()
|
|
|
+ console.info('麦克风权限验证结束 : ', microInfo)
|
|
|
+ if (mode === 'video') {
|
|
|
+ console.info('验证摄像头权限')
|
|
|
+ const camerasInfo = await AgoraRTC.getCameras()
|
|
|
+ console.info('摄像头权限验证结束 : ', camerasInfo)
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
}
|
|
|
- } catch (error) {
|
|
|
- console.error(error)
|
|
|
+ console.info('相关权限验证结束')
|
|
|
}
|
|
|
- console.info('相关权限验证结束')
|
|
|
-
|
|
|
initRtcClient()
|
|
|
|
|
|
await getRtcOption()
|
|
@@ -335,17 +341,20 @@ async function handleAudioChatStart() {
|
|
|
console.info('发送拨号信息结束')
|
|
|
|
|
|
await nextTick(async () => {
|
|
|
- console.info('初始化rtc频道')
|
|
|
- await rtcInstance.client!.join(rtcOptions.appId, rtcOptions.channel, rtcOptions?.token, /*rtcOptions.uid*/ user.user_id);
|
|
|
- console.info('初始化rtc频道结束,开始创建本地音视频轨道')
|
|
|
- rtcInstance.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
|
|
|
- // await rtcInstance.client!.publish(rtcInstance.localAudioTrack);
|
|
|
- if (mode === 'video') {
|
|
|
- console.info('创建本地视频轨道')
|
|
|
- rtcInstance.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
|
|
|
- console.info('创建本地视频轨道结束,开始播放本地视频')
|
|
|
- rtcInstance.localVideoTrack.play(LocalPlayerContainerRef as HTMLElement);
|
|
|
- // await rtcInstance.client!.publish(rtcInstance.localVideoTrack);
|
|
|
+ if (RTC_USE) {
|
|
|
+
|
|
|
+ console.info('初始化rtc频道')
|
|
|
+ await rtcInstance.client!.join(rtcOptions.appId, rtcOptions.channel, rtcOptions?.token, /*rtcOptions.uid*/ user.user_id);
|
|
|
+ console.info('初始化rtc频道结束,开始创建本地音视频轨道')
|
|
|
+ rtcInstance.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
|
|
|
+ // await rtcInstance.client!.publish(rtcInstance.localAudioTrack);
|
|
|
+ if (mode === 'video') {
|
|
|
+ console.info('创建本地视频轨道')
|
|
|
+ rtcInstance.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
|
|
|
+ console.info('创建本地视频轨道结束,开始播放本地视频')
|
|
|
+ rtcInstance.localVideoTrack.play(LocalPlayerContainerRef as HTMLElement);
|
|
|
+ // await rtcInstance.client!.publish(rtcInstance.localVideoTrack);
|
|
|
+ }
|
|
|
}
|
|
|
console.info('socket发送拨号信息')
|
|
|
socketSend(ws2, {
|
|
@@ -377,7 +386,8 @@ async function handleAudioChatCancel() {
|
|
|
fullSendData
|
|
|
})
|
|
|
isOpen = false
|
|
|
- rtcInstance.client?.leave();
|
|
|
+ if (RTC_USE)
|
|
|
+ rtcInstance.client?.leave();
|
|
|
handleSwitchUse(false)
|
|
|
console.info('[success]handleAudioChatCancel end')
|
|
|
} catch (error) {
|
|
@@ -394,25 +404,27 @@ async function handleAudioChatAccept() {
|
|
|
const fullSendData = await handleInfoEdit({ dxzl_status: '3' }, '通话中')
|
|
|
console.info('发送接听信息结束')
|
|
|
// ...
|
|
|
- console.info('初始化rtc频道')
|
|
|
- initRtcClient()
|
|
|
+ if (RTC_USE) {
|
|
|
+ console.info('初始化rtc频道')
|
|
|
+ initRtcClient()
|
|
|
|
|
|
- await getRtcOption()
|
|
|
- console.info('初始化rtc频道')
|
|
|
- await rtcInstance.client!.join(rtcOptions.appId, rtcOptions.channel, rtcOptions?.token, /*rtcOptions.uid*/ user.user_id);
|
|
|
- console.info('初始化rtc频道结束,开始创建本地音视频轨道')
|
|
|
- rtcInstance.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
|
|
|
- console.info('创建本地音频轨道结束,发布本地音频')
|
|
|
- await rtcInstance.client!.publish(rtcInstance.localAudioTrack);
|
|
|
- console.info('发布本地音频结束')
|
|
|
- if (mode === 'video') {
|
|
|
- console.info('创建本地视频轨道')
|
|
|
- rtcInstance.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
|
|
|
- console.info('创建本地视频轨道结束,开始播放本地视频')
|
|
|
- rtcInstance.localVideoTrack.play(LocalPlayerContainerRef as HTMLElement);
|
|
|
- console.info('发布本地视频')
|
|
|
- await rtcInstance.client!.publish(rtcInstance.localVideoTrack);
|
|
|
- console.info('发布本地视频结束')
|
|
|
+ await getRtcOption()
|
|
|
+ console.info('初始化rtc频道')
|
|
|
+ await rtcInstance.client!.join(rtcOptions.appId, rtcOptions.channel, rtcOptions?.token, /*rtcOptions.uid*/ user.user_id);
|
|
|
+ console.info('初始化rtc频道结束,开始创建本地音视频轨道')
|
|
|
+ rtcInstance.localAudioTrack = await AgoraRTC.createMicrophoneAudioTrack();
|
|
|
+ console.info('创建本地音频轨道结束,发布本地音频')
|
|
|
+ await rtcInstance.client!.publish(rtcInstance.localAudioTrack);
|
|
|
+ console.info('发布本地音频结束')
|
|
|
+ if (mode === 'video') {
|
|
|
+ console.info('创建本地视频轨道')
|
|
|
+ rtcInstance.localVideoTrack = await AgoraRTC.createCameraVideoTrack();
|
|
|
+ console.info('创建本地视频轨道结束,开始播放本地视频')
|
|
|
+ rtcInstance.localVideoTrack.play(LocalPlayerContainerRef as HTMLElement);
|
|
|
+ console.info('发布本地视频')
|
|
|
+ await rtcInstance.client!.publish(rtcInstance.localVideoTrack);
|
|
|
+ console.info('发布本地视频结束')
|
|
|
+ }
|
|
|
}
|
|
|
//
|
|
|
console.info('socket发送已接听信息')
|
|
@@ -455,8 +467,10 @@ async function handleAudioChatEnd() {
|
|
|
try {
|
|
|
const fullSendData = await handleInfoEdit({ dxzl_status: '4' }, /*'已结束'*/formatOffsetSec(offsetTime))
|
|
|
offsetTimer && clearInterval(offsetTimer)
|
|
|
- await rtcInstance.client!.leave();
|
|
|
- handleSwitchUse(false)
|
|
|
+ if (RTC_USE) {
|
|
|
+ await rtcInstance.client!.leave();
|
|
|
+ handleSwitchUse(false)
|
|
|
+ }
|
|
|
|
|
|
socketSend(ws2, {
|
|
|
dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
@@ -476,6 +490,8 @@ let audioInUse = $ref(true)
|
|
|
let videoInUse = $ref(true)
|
|
|
|
|
|
function handleSwitchAudio(v?: boolean) {
|
|
|
+ if (!RTC_USE) return
|
|
|
+
|
|
|
audioInUse = v ?? !audioInUse
|
|
|
try {
|
|
|
rtcInstance.localAudioTrack!.setEnabled(audioInUse)
|
|
@@ -485,6 +501,8 @@ function handleSwitchAudio(v?: boolean) {
|
|
|
|
|
|
}
|
|
|
function handleSwitchVideo(v?: boolean) {
|
|
|
+ if (!RTC_USE) return
|
|
|
+
|
|
|
videoInUse = v ?? !videoInUse
|
|
|
try {
|
|
|
rtcInstance.localVideoTrack!.setEnabled(videoInUse)
|