Compare commits
No commits in common. "be79430fc01faede3754c638ebbdb73afe6972fb" and "52fd0e34107327a229607a9477553cb3cfa39e95" have entirely different histories.
be79430fc0
...
52fd0e3410
|
|
@ -40,7 +40,6 @@
|
||||||
.stupWizardRight {
|
.stupWizardRight {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: relative;
|
|
||||||
|
|
||||||
>div {
|
>div {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
@ -59,7 +58,6 @@
|
||||||
>div {
|
>div {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overflow-x: hidden;
|
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
@ -73,16 +71,10 @@
|
||||||
height: 296px;
|
height: 296px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
border: 1px #292E33 solid;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
>video {
|
>video {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
z-index: 1;
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import ImageUrl from '@/utils/package/ImageUrl';
|
||||||
import { Button, Empty, message, Modal, Select, Slider } from 'antd';
|
import { Button, Empty, message, Modal, Select, Slider } from 'antd';
|
||||||
import { useState, useImperativeHandle, forwardRef, useEffect } from "react";
|
import { useState, useImperativeHandle, forwardRef, useEffect } from "react";
|
||||||
import agora from '@/utils/package/agora'
|
import agora from '@/utils/package/agora'
|
||||||
import { CloseOutlined, LoadingOutlined } from '@ant-design/icons';
|
|
||||||
const StupWizard = forwardRef((props: any, ref: any) => {
|
const StupWizard = forwardRef((props: any, ref: any) => {
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
changeModal: () => {
|
changeModal: () => {
|
||||||
|
|
@ -67,7 +66,6 @@ const StupWizard = forwardRef((props: any, ref: any) => {
|
||||||
open={isStupWizard}
|
open={isStupWizard}
|
||||||
footer={null}
|
footer={null}
|
||||||
closable={false}
|
closable={false}
|
||||||
destroyOnClose={true}
|
|
||||||
centered
|
centered
|
||||||
width={'70vw'}
|
width={'70vw'}
|
||||||
className='modal-padding'>
|
className='modal-padding'>
|
||||||
|
|
@ -75,13 +73,10 @@ const StupWizard = forwardRef((props: any, ref: any) => {
|
||||||
<div className={styles.stupWizardLeft}>
|
<div className={styles.stupWizardLeft}>
|
||||||
{list.map((row: any, index: number) => {
|
{list.map((row: any, index: number) => {
|
||||||
return (
|
return (
|
||||||
<div key={index} className={`${row.active ? styles.active : ''}`} onClick={async () => {
|
<div key={index} className={`${row.active ? styles.active : ''}`} onClick={() => {
|
||||||
const newList = [...list]
|
const newList = [...list]
|
||||||
newList.forEach(item => item.active = false)
|
newList.forEach(item => item.active = false)
|
||||||
newList[index].active = true;
|
newList[index].active = true;
|
||||||
if (newList[index].title !== '视频') {
|
|
||||||
await agora.stopVideoDevice('videoPreview')
|
|
||||||
}
|
|
||||||
setList(newList)
|
setList(newList)
|
||||||
}}>
|
}}>
|
||||||
<img src={row.active ? row.iconActive : row.icon} alt="" />
|
<img src={row.active ? row.iconActive : row.icon} alt="" />
|
||||||
|
|
@ -91,22 +86,10 @@ const StupWizard = forwardRef((props: any, ref: any) => {
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.stupWizardRight}>
|
<div className={styles.stupWizardRight}>
|
||||||
<CloseOutlined style={{
|
|
||||||
position: 'absolute',
|
|
||||||
color: 'white',
|
|
||||||
right: '20px',
|
|
||||||
top: '16px',
|
|
||||||
cursor: 'pointer'
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
agora.stopVideoDevice('videoPreview')
|
|
||||||
setIsStupWizard(false)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{list[0].active ? <VideoComponents /> : null}
|
{list[0].active ? <VideoComponents /> : null}
|
||||||
{list[1].active ? <AudioComponents /> : null}
|
{list[1].active ? <AudioComponents /> : null}
|
||||||
{list[2].active ? <RecordingComponents /> : null}
|
{list[2].active ? <RecordingComponents /> : null}
|
||||||
{list[3].active ? <FileComponents /> : null}
|
{list[3].active ? <RecordingComponents /> : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
@ -123,7 +106,7 @@ const VideoComponents = () => {
|
||||||
getVideoDeviceList()
|
getVideoDeviceList()
|
||||||
}, []);
|
}, []);
|
||||||
const getVideoDeviceList = (): void => {
|
const getVideoDeviceList = (): void => {
|
||||||
agora.getVideoDeviceManager().then(async (res) => {
|
agora.getVideoDeviceManager().then(res => {
|
||||||
const { item, list } = res
|
const { item, list } = res
|
||||||
setVideoDeviceManager({
|
setVideoDeviceManager({
|
||||||
list: list.map((row: any) => {
|
list: list.map((row: any) => {
|
||||||
|
|
@ -134,10 +117,7 @@ const VideoComponents = () => {
|
||||||
}),
|
}),
|
||||||
item: item ? item : null,
|
item: item ? item : null,
|
||||||
})
|
})
|
||||||
if (item) {
|
agora.startPreview('videoPreview')
|
||||||
await agora.stopVideoDevice('videoPreview')
|
|
||||||
agora.startPreview('videoPreview', item)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
|
@ -148,14 +128,7 @@ const VideoComponents = () => {
|
||||||
{
|
{
|
||||||
videoDeviceManager.item ?
|
videoDeviceManager.item ?
|
||||||
<div>
|
<div>
|
||||||
<video id='videoPreview'></video>
|
<video id='videoPreview' controls></video>
|
||||||
<LoadingOutlined style={{
|
|
||||||
position: 'absolute',
|
|
||||||
color: 'white',
|
|
||||||
right: '50%',
|
|
||||||
fontSize: '30px',
|
|
||||||
top: '50%',
|
|
||||||
}} />
|
|
||||||
</div> :
|
</div> :
|
||||||
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}><Empty description={'未检测到摄像头'} /></div>
|
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}><Empty description={'未检测到摄像头'} /></div>
|
||||||
}
|
}
|
||||||
|
|
@ -165,12 +138,7 @@ const VideoComponents = () => {
|
||||||
placeholder={videoDeviceManager.list.length ? '请选择设备' : '未检测到摄像头'}
|
placeholder={videoDeviceManager.list.length ? '请选择设备' : '未检测到摄像头'}
|
||||||
options={videoDeviceManager.list} style={{ flexGrow: 1 }}
|
options={videoDeviceManager.list} style={{ flexGrow: 1 }}
|
||||||
value={videoDeviceManager.item} onChange={(e) => {
|
value={videoDeviceManager.item} onChange={(e) => {
|
||||||
setVideoDeviceManager({
|
|
||||||
...videoDeviceManager,
|
|
||||||
item: e
|
|
||||||
})
|
|
||||||
agora.setVideoDeviceManager(e)
|
|
||||||
agora.startPreview('videoPreview', e)
|
|
||||||
}} />;
|
}} />;
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -270,17 +270,11 @@ const agora = {
|
||||||
item: rtcEngine.getVideoDeviceManager().getDevice()
|
item: rtcEngine.getVideoDeviceManager().getDevice()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 通过设备 ID 指定视频采集设备。
|
|
||||||
setVideoDeviceManager: (deviceIdUTF8: string) => {
|
|
||||||
rtcEngine.getVideoDeviceManager().setDevice(deviceIdUTF8)
|
|
||||||
},
|
|
||||||
// 开启本地视频预览
|
// 开启本地视频预览
|
||||||
startPreview: async (id: string, deviceId: string): Promise<boolean> => {
|
startPreview: async (id: string): Promise<boolean> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
navigator.mediaDevices.getUserMedia({
|
navigator.mediaDevices.getUserMedia({
|
||||||
video: {
|
video: true,
|
||||||
deviceId: { exact: deviceId }, // 指定设备ID
|
|
||||||
},
|
|
||||||
audio: true,
|
audio: true,
|
||||||
}).then((stream) => {
|
}).then((stream) => {
|
||||||
let dom = document.getElementById(id) as any;
|
let dom = document.getElementById(id) as any;
|
||||||
|
|
@ -294,16 +288,7 @@ const agora = {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
stopVideoDevice: async (id: string) => {
|
|
||||||
let dom = document.getElementById(id) as any;
|
|
||||||
if (dom && dom.srcObject) {
|
|
||||||
const tracks = dom.srcObject.getTracks();
|
|
||||||
tracks.forEach((track: any) => {
|
|
||||||
track.stop();
|
|
||||||
});
|
|
||||||
dom.srcObject = null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue