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

pull/1989/head
lyswhut 2024-05-14 19:27:55 +08:00
parent 2ee7572634
commit 97d3d3c616
4 changed files with 15 additions and 0 deletions

View File

@ -182,6 +182,7 @@
"lyric_menu__size_add": "Increase font size (right click to fine-tune)",
"lyric_menu__size_dec": "Decrease font (right click to fine tune)",
"lyric_menu__size_reset": "Reset",
"media_device__emtpy_device_tip": "The audio output device is empty. If it cannot be played, please check whether the sound card driver has been installed or reinstall the sound card driver!",
"min": "Minimize",
"music_album": "Album",
"music_duplicate": "Duplicate song",

View File

@ -182,6 +182,7 @@
"lyric_menu__size_add": "加大字体(右击可微调)",
"lyric_menu__size_dec": "减小字体(右击可微调)",
"lyric_menu__size_reset": "重置",
"media_device__emtpy_device_tip": "音频输出设备为空,若出现无法播放的情况,请检查声卡驱动是否已安装或重装声卡驱动!",
"min": "最小化",
"music_album": "专辑名",
"music_duplicate": "重复歌曲",

View File

@ -182,6 +182,7 @@
"lyric_menu__size_add": "加大字體(右鍵可微調)",
"lyric_menu__size_dec": "減小字體(右鍵可微調)",
"lyric_menu__size_reset": "重置",
"media_device__emtpy_device_tip": "音訊輸出裝置為空,若出現無法播放的狀況,請檢查音效卡驅動是否已安裝或重裝音效卡驅動!",
"min": "最小化",
"music_album": "專輯名",
"music_duplicate": "重複歌曲",

View File

@ -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) => {