change device
This commit is contained in:
parent
c3d3e737b7
commit
ac94990547
|
|
@ -10,7 +10,7 @@ export default defineComponent({
|
|||
props: {
|
||||
|
||||
},
|
||||
emits: ['init'],
|
||||
emits: ['init', 'switch'],
|
||||
setup(props, { emit }) {
|
||||
const data = reactive({
|
||||
videoList: [],
|
||||
|
|
@ -30,10 +30,11 @@ export default defineComponent({
|
|||
})
|
||||
}
|
||||
|
||||
const handleReverse = () => {
|
||||
const handleCameraReverse = () => {
|
||||
const index = data.videoList.findIndex((item) => item.deviceId === data.videoDeviceId)
|
||||
const len = data.videoList.length
|
||||
if (len === 1) {
|
||||
alert(len)
|
||||
if (len <= 1) {
|
||||
return
|
||||
} else if (index === 0) {
|
||||
data.videoDeviceId = data.videoList[len - 1].deviceId
|
||||
|
|
@ -41,12 +42,14 @@ export default defineComponent({
|
|||
cameraId: data.videoDeviceId,
|
||||
microphoneId: data.audioDeviceId
|
||||
})
|
||||
emit('switch', { type: 'video', deviceId: data.cameraId })
|
||||
} else {
|
||||
data.videoDeviceId = data.deviceList[0].deviceId
|
||||
data.videoDeviceId = data.videoList[0].deviceId
|
||||
emit('init', {
|
||||
cameraId: data.videoDeviceId,
|
||||
microphoneId: data.audioDeviceId
|
||||
})
|
||||
emit('switch', { type: 'video', deviceId: data.cameraId })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -63,7 +66,7 @@ export default defineComponent({
|
|||
|
||||
return {
|
||||
...toRefs(data),
|
||||
handleReverse
|
||||
handleCameraReverse
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ export default {
|
|||
*/
|
||||
const handelCameraReverse = () => {
|
||||
if (!status.isMutedVideo) {
|
||||
cameraRef.value.handleReverse()
|
||||
cameraRef.value.handleCameraReverse()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue