This commit is contained in:
parent
043e86ed08
commit
8e0bfa8ce8
|
|
@ -1,9 +1,7 @@
|
|||
import { GetCheckoutRoomNum, GetRoomInfo, GetRoomRtcToken } from '@/api/Home/Index';
|
||||
import styles from '@/components/JoinMeetingModal/index.module.scss'
|
||||
import ImageUrl from '@/utils/package/ImageUrl';
|
||||
import { Modal, message } from 'antd';
|
||||
import { useState, useImperativeHandle, forwardRef, useRef } from "react";
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import Avatar from '@/components/Avatar';
|
||||
import JoinSetting from '../JoinSetting';
|
||||
const JoinMeetingModal = forwardRef((props: any, ref: any) => {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {
|
|||
})
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
agora.init()
|
||||
agora.setDeviceManager()
|
||||
}
|
||||
getDeviceList()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,15 @@ const StupWizard = forwardRef((props: any, ref: any) => {
|
|||
changeModal: () => {
|
||||
if (location.hash.indexOf('/meeting') === -1) {
|
||||
agora.init()
|
||||
agora.setDeviceManager()
|
||||
}
|
||||
setList((res: any) => {
|
||||
res.forEach((item: any) => {
|
||||
item.active = false
|
||||
});
|
||||
res[0].active = true;
|
||||
return res
|
||||
})
|
||||
setIsStupWizard(true)
|
||||
}
|
||||
}))
|
||||
|
|
@ -148,13 +156,6 @@ const VideoComponents = () => {
|
|||
const userInfo = JSON.parse(storage.getItem('user') as string)
|
||||
agora.getVideoDeviceManager().then(async (res) => {
|
||||
const { item, list } = res
|
||||
if ((!setting.videoDeviceId && item) || (!(list.find((item: any) => item.deviceId === setting.videoDeviceId)) && item)) {
|
||||
setting.videoDeviceId = item
|
||||
}
|
||||
if (!list.length) {
|
||||
setting.videoDeviceId = ''
|
||||
}
|
||||
storage.setItem('setting', JSON.stringify(setting))
|
||||
setVideoDeviceManager({
|
||||
list: list.map((row: any) => {
|
||||
return {
|
||||
|
|
@ -260,29 +261,14 @@ const AudioComponents = () => {
|
|||
const {
|
||||
playBackList,
|
||||
ecordingList,
|
||||
playBackItem,
|
||||
ecordingItem,
|
||||
ecordingVolume
|
||||
} = await agora.getAudioMediaList();
|
||||
if ((!setting.ecordingDeviceId && ecordingItem.deviceId) || (!(ecordingList.find((item: any) => item.deviceId === setting.ecordingDeviceId)) && ecordingItem.deviceId)) {
|
||||
setting.ecordingDeviceId = ecordingItem.deviceId
|
||||
}
|
||||
if ((!setting.playBackDeviceId && playBackItem.deviceId) || (!(playBackList.find((item: any) => item.deviceId === setting.playBackDeviceId)) && playBackItem.deviceId)) {
|
||||
setting.playBackDeviceId = playBackItem.deviceId
|
||||
}
|
||||
if (!ecordingList.length) {
|
||||
setting.ecordingDeviceId = ''
|
||||
}
|
||||
if (!playBackList.length) {
|
||||
setting.playBackDeviceId = ''
|
||||
}
|
||||
if (!setting.ecordingVolume) {
|
||||
setting.ecordingVolume = ecordingVolume;
|
||||
}
|
||||
if (!setting.playBackVolume) {
|
||||
setting.playBackVolume = 127;
|
||||
}
|
||||
storage.setItem('setting', JSON.stringify(setting))
|
||||
setAudioDeviceManager({
|
||||
...audioDeviceManager,
|
||||
playBackList: playBackList.map((row: any) => {
|
||||
|
|
@ -297,8 +283,8 @@ const AudioComponents = () => {
|
|||
label: row.deviceName
|
||||
}
|
||||
}),
|
||||
playBackItem: setting.playBackDeviceId ? setting.playBackDeviceId : playBackItem.deviceId || null,
|
||||
ecordingItem: setting.ecordingDeviceId ? setting.ecordingDeviceId : ecordingItem.deviceId || null,
|
||||
playBackItem: setting.playBackDeviceId,
|
||||
ecordingItem: setting.ecordingDeviceId,
|
||||
ecordingVolume: setting.ecordingVolume,
|
||||
playBackVolume: setting.playBackVolume,
|
||||
autoEcordingVolume: setting.autoEcordingVolume
|
||||
|
|
|
|||
|
|
@ -26,24 +26,69 @@ const agora = {
|
|||
});
|
||||
if (bool) {
|
||||
const setting = JSON.parse(storage.getItem('setting') as string)
|
||||
if (setting.videoDeviceId) {
|
||||
agora.getVideoDeviceManager().then(async (res) => {
|
||||
let item = res.list.find((item: any) => item.deviceId === setting.videoDeviceId);
|
||||
if (item) {
|
||||
agora.setVideoDeviceManager(setting.videoDeviceId) //通过设备 ID 指定视频采集设备。
|
||||
} else {
|
||||
agora.setVideoDeviceManager(rtcEngine.getVideoDeviceManager().getDevice())
|
||||
}
|
||||
})
|
||||
} else {
|
||||
agora.setVideoDeviceManager(rtcEngine.getVideoDeviceManager().getDevice())
|
||||
}
|
||||
if (setting.videoDeviceId) agora.setVideoDeviceManager(setting.videoDeviceId) //指定摄像头头采集设备
|
||||
if (setting.playBackDeviceId) agora.setPlaybackDevice(setting.playBackDeviceId) //指定播放设备
|
||||
if (setting.playBackVolume) agora.setPlaybackDeviceVolume(setting.playBackVolume) // 设置播放设备音量
|
||||
if (setting.ecordingDeviceId) agora.setRecordingDevice(setting.ecordingDeviceId) // 设置音频采集设备
|
||||
if (setting.ecordingVolume) agora.setRecordingDeviceVolume(setting.ecordingVolume) // 设置音频设备音量
|
||||
}
|
||||
},
|
||||
// 获取当前设备是否存在不存在就获取默认设备
|
||||
setDeviceManager: async () => {
|
||||
const setting = JSON.parse(storage.getItem('setting') as string)
|
||||
// 摄像头
|
||||
if (setting.videoDeviceId) {
|
||||
agora.getVideoDeviceManager().then(async (res) => {
|
||||
let item = res.list.find((item: any) => item.deviceId === setting.videoDeviceId);
|
||||
if (item) {
|
||||
agora.setVideoDeviceManager(setting.videoDeviceId)
|
||||
} else {
|
||||
agora.setVideoDeviceManager(rtcEngine.getVideoDeviceManager().getDevice())
|
||||
setting.videoDeviceId = rtcEngine.getVideoDeviceManager().getDevice()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
agora.setVideoDeviceManager(rtcEngine.getVideoDeviceManager().getDevice())
|
||||
setting.videoDeviceId = rtcEngine.getVideoDeviceManager().getDevice()
|
||||
}
|
||||
|
||||
// 播放设备
|
||||
if (setting.playBackDeviceId) {
|
||||
agora.getAudioMediaList().then(async (res) => {
|
||||
let item = res.playBackList.find((item: any) => item.deviceId === setting.playBackDeviceId);
|
||||
if (item) {
|
||||
agora.setPlaybackDevice(setting.playBackDeviceId)
|
||||
} else {
|
||||
agora.setPlaybackDevice(res.playBackItem.deviceId)
|
||||
setting.playBackDeviceId = res.playBackItem.deviceId
|
||||
}
|
||||
})
|
||||
} else {
|
||||
let deviceId = rtcEngine.getAudioDeviceManager().getPlaybackDefaultDevice().deviceId;
|
||||
agora.setPlaybackDevice(deviceId)
|
||||
setting.playBackDeviceId = deviceId
|
||||
}
|
||||
|
||||
// 音频设备
|
||||
if (setting.ecordingDeviceId) {
|
||||
agora.getAudioMediaList().then(async (res) => {
|
||||
let item = res.ecordingList.find((item: any) => item.deviceId === setting.ecordingDeviceId);
|
||||
if (item) {
|
||||
agora.setRecordingDevice(setting.ecordingDeviceId)
|
||||
} else {
|
||||
agora.setRecordingDevice(res.ecordingItem.deviceId)
|
||||
setting.ecordingDeviceId = res.ecordingItem.deviceId
|
||||
}
|
||||
})
|
||||
} else {
|
||||
let deviceId = rtcEngine.getAudioDeviceManager().getRecordingDefaultDevice().deviceId;
|
||||
agora.setRecordingDevice(deviceId)
|
||||
setting.ecordingDeviceId = deviceId
|
||||
}
|
||||
setTimeout(() => {
|
||||
storage.setItem('setting', JSON.stringify(setting))
|
||||
}, 1000);
|
||||
},
|
||||
// 事件回调
|
||||
registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication }: any) => {
|
||||
rtcEngine.registerEventHandler({
|
||||
|
|
|
|||
Loading…
Reference in New Issue