浏览代码

change device

master
zhangtao 2 年前
父节点
当前提交
ac94990547
共有 2 个文件被更改,包括 9 次插入6 次删除
  1. +8
    -5
      src/views/home/components/Device.vue
  2. +1
    -1
      src/views/home/index.vue

+ 8
- 5
src/views/home/components/Device.vue 查看文件

@@ -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
}
}


+ 1
- 1
src/views/home/index.vue 查看文件

@@ -504,7 +504,7 @@ export default {
*/
const handelCameraReverse = () => {
if (!status.isMutedVideo) {
cameraRef.value.handleReverse()
cameraRef.value.handleCameraReverse()
}
}


正在加载...
取消
保存