From fc0367c9b480beacde18f303b788cc7256f04a42 Mon Sep 17 00:00:00 2001 From: Vidocq <949867756@qq.com> Date: Sat, 6 Mar 2021 21:48:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20open=20microphone=20whenever=20enter=20s?= =?UTF-8?q?etting=20page=20|=20=E5=88=A0=E9=99=A4=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=BA=A6=E5=85=8B=E9=A3=8E=E6=9D=83=E9=99=90=20(#350)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: bugs * delete getMediaUser Co-authored-by: qier222 --- src/locale/lang/en.js | 1 - src/locale/lang/zh-CN.js | 1 - src/views/settings.vue | 27 ++++++++++++--------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/locale/lang/en.js b/src/locale/lang/en.js index 29983e4..9337d75 100644 --- a/src/locale/lang/en.js +++ b/src/locale/lang/en.js @@ -119,7 +119,6 @@ export default { lossless: "Lossless", }, deviceSelector: "Audio Output Device", - permissionDenied: "Microphone Permission Denied", permissionRequired: "Microphone Permission Required", appearance: { text: "Appearance", diff --git a/src/locale/lang/zh-CN.js b/src/locale/lang/zh-CN.js index 10c7eec..3b7e0a1 100644 --- a/src/locale/lang/zh-CN.js +++ b/src/locale/lang/zh-CN.js @@ -120,7 +120,6 @@ export default { lossless: "无损", }, deviceSelector: "音频输出设备", - permissionDenied: "无麦克风权限", permissionRequired: "需要麦克风权限", appearance: { text: "外观", diff --git a/src/views/settings.vue b/src/views/settings.vue index b293a05..7a51c6c 100644 --- a/src/views/settings.vue +++ b/src/views/settings.vue @@ -401,27 +401,24 @@ export default { }, methods: { getAllOutputDevices() { - navigator.mediaDevices - .getUserMedia({ audio: true }) - .then(() => { + navigator.mediaDevices.enumerateDevices().then((devices) => { + this.allOutputDevices = devices.filter((device) => { + return device.kind == "audiooutput"; + }); + if ( + this.allOutputDevices.length > 0 && + this.allOutputDevices[0].label !== "" + ) { this.withoutAudioPriviledge = false; - navigator.mediaDevices - .enumerateDevices() - .then( - (devices) => - (this.allOutputDevices = devices.filter( - (device) => device.kind == "audiooutput" - )) - ); - }) - .catch(() => { + } else { this.allOutputDevices = [ { deviceId: "default", - label: "settings.permissionDenied", + label: "settings.permissionRequired", }, ]; - }); + } + }); }, logout() { doLogout();