添加媒体输出设备检测提示

This commit is contained in:
lyswhut
2024-05-14 19:27:55 +08:00
parent 2ee7572634
commit 97d3d3c616
4 changed files with 15 additions and 0 deletions
@@ -3,6 +3,7 @@ import {
watch,
} from '@common/utils/vueTools'
import { pause } from '@renderer/core/player/action'
import { dialog } from '@renderer/plugins/Dialog'
import { setMediaDeviceId } from '@renderer/plugins/player'
import { isPlay } from '@renderer/store/player/state'
import { appSetting, saveMediaDeviceId } from '@renderer/store/setting'
@@ -12,6 +13,8 @@ const getDevices = async() => {
return devices.filter(({ kind }) => kind == 'audiooutput')
}
let isShowingTipAlert = false
export default () => {
let prevDeviceLabel: string | null = null
let prevDeviceId = ''
@@ -24,6 +27,15 @@ export default () => {
device = devices.find(device => device.deviceId === deviceId)
}
if (!device && !devices.length && !isShowingTipAlert) {
isShowingTipAlert = true
void dialog({
message: window.i18n.t('media_device__emtpy_device_tip'),
confirmButtonText: window.i18n.t('ok'),
}).finally(() => {
isShowingTipAlert = false
})
}
return device ? { label: device.label, deviceId: device.deviceId } : { label: '', deviceId: '' }
}
const setMediaDevice = async(deviceId: string, label: string) => {