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