浏览代码

change device

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

+ 2
- 3
src/views/home/components/Device.vue 查看文件

@@ -33,7 +33,6 @@ export default defineComponent({
const handleCameraReverse = () => {
const index = data.videoList.findIndex((item) => item.deviceId === data.videoDeviceId)
const len = data.videoList.length
alert(len)
if (len <= 1) {
return
} else if (index === 0) {
@@ -42,14 +41,14 @@ export default defineComponent({
cameraId: data.videoDeviceId,
microphoneId: data.audioDeviceId
})
emit('switch', { type: 'video', deviceId: data.cameraId })
emit('switch', { type: 'video', cameraId: data.videoDeviceId })
} else {
data.videoDeviceId = data.videoList[0].deviceId
emit('init', {
cameraId: data.videoDeviceId,
microphoneId: data.audioDeviceId
})
emit('switch', { type: 'video', deviceId: data.cameraId })
emit('switch', { type: 'video', cameraId: data.videoDeviceId })
}
}


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

@@ -1,8 +1,8 @@
<template>
<div class="room">
<!-- <DeviceSelect v-show="false" ref="cameraRef" v-model:value="cameraId" device-type="video" @switch="handleDeviceSwitch" /> -->
<!-- <DeviceSelect v-show="false" v-model:value="microphoneId" device-type="audio" @switch="handleDeviceSwitch" /> -->
<Device ref="cameraRef" @init="deviceInit" @switch="handleDeviceSwitch" />
<!-- <DeviceSelect v-show="false" ref="cameraRef" v-model:value="cameraId" device-type="video" @switch="handleCamareSwitch" /> -->
<!-- <DeviceSelect v-show="false" v-model:value="microphoneId" device-type="audio" /> -->
<Device ref="cameraRef" @init="deviceInit" @switch="handleCamareSwitch" />

<!-- 远端 -->
<div class="remote-container">
@@ -427,13 +427,13 @@ export default {
/**
* @description: 切换音频
* @param {*} type
* @param {*} deviceId
* @param {*} cameraId
* @return {*}
*/
const handleDeviceSwitch = ({ type, deviceId }) => {
const handleCamareSwitch = ({ type, cameraId }) => {
try {
if (settings.localStream) {
settings.localStream.switchDevice(type, deviceId)
settings.localStream.switchDevice(type, cameraId)
}
} catch (error) {
console.error('switchDevice failed', error)
@@ -557,7 +557,7 @@ export default {
handleAudioMute,
handleAudioUnMute,
handelCameraReverse,
handleDeviceSwitch,
handleCamareSwitch,
leaveMeetingRoom
}
}

正在加载...
取消
保存