This commit is contained in:
yj 2024-08-14 16:32:51 +08:00
parent de5cda5b3c
commit 938df73910
1 changed files with 24 additions and 35 deletions

View File

@ -33,10 +33,6 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {
})) }))
const navigate = useNavigate(); const navigate = useNavigate();
const [user, setUser] = useState<any>({}); const [user, setUser] = useState<any>({});
const [deviceList, setDeviceList] = useState<any>({
audioList: [],
videoList: [],
});
const [joinRoomSettingModal, setJoinRoomSettingModal] = useState(false) const [joinRoomSettingModal, setJoinRoomSettingModal] = useState(false)
const [joinRoomSettingForm, setJoinRoomSettingForm] = useState({ const [joinRoomSettingForm, setJoinRoomSettingForm] = useState({
list: [ list: [
@ -59,10 +55,6 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {
time = setInterval(async () => { time = setInterval(async () => {
const list = [...joinRoomSettingForm.list] const list = [...joinRoomSettingForm.list]
await agora.getAudioMediaList().then(res => { await agora.getAudioMediaList().then(res => {
setDeviceList({
...deviceList,
audioList: res.ecordingList
})
if (!res.ecordingList.length) { if (!res.ecordingList.length) {
list[0].active = false list[0].active = false
setJoinRoomSettingForm({ setJoinRoomSettingForm({
@ -72,10 +64,6 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {
} }
}) })
await agora.getVideoDeviceManager().then(res => { await agora.getVideoDeviceManager().then(res => {
setDeviceList({
...deviceList,
videoList: res.list
})
if (!res.list.length) { if (!res.list.length) {
list[1].active = false list[1].active = false
setJoinRoomSettingForm({ setJoinRoomSettingForm({
@ -148,17 +136,20 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {
<div> <div>
{ {
joinRoomSettingForm.list.map((item, index) => { joinRoomSettingForm.list.map((item, index) => {
return <div key={index} onClick={() => { return <div key={index} onClick={async () => {
let msg = ''; let msg = '';
setDeviceList((res: any) => {
if (index === 0) { if (index === 0) {
if (!res.audioList.length) { await agora.getAudioMediaList().then(res => {
if (!res.ecordingList.length) {
msg = '未检测到麦克风!' msg = '未检测到麦克风!'
} }
})
} else { } else {
if (!res.videoList.length) { await agora.getVideoDeviceManager().then(res => {
msg = '未检测到麦克风!' if (!res.list.length) {
msg = '未检测到摄像头!'
} }
})
} }
if (msg) { if (msg) {
message.error('未检测到麦克风!') message.error('未检测到麦克风!')
@ -175,8 +166,6 @@ const JoinSetting = forwardRef((_props: any, ref: any) => {
agora.startPreview('videoPreview', Number(user.account)) agora.startPreview('videoPreview', Number(user.account))
} }
} }
return res
})
}}> }}>
<img src={item.active ? item.icon : item.iconActive} alt="" /> <img src={item.active ? item.icon : item.iconActive} alt="" />
</div> </div>