新增 设置-播放设置-使用设备能处理的最大声道数输出音频 设置(#1873)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { watch } from '@common/utils/vueTools'
|
||||
import { setMaxOutputChannelCount } from '@renderer/plugins/player'
|
||||
|
||||
import { appSetting } from '@renderer/store/setting'
|
||||
|
||||
export default () => {
|
||||
// console.log(appSetting['player.soundEffect.panner.enable'])
|
||||
setMaxOutputChannelCount(appSetting['player.isMaxOutputChannelCount'])
|
||||
|
||||
watch(() => appSetting['player.isMaxOutputChannelCount'], (val) => {
|
||||
setMaxOutputChannelCount(val)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -41,16 +41,16 @@ export default () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleDeviceChangeStopPlay = (label: string) => {
|
||||
const handleDeviceChange = (label: string) => {
|
||||
// console.log(device)
|
||||
// console.log(appSetting['player.isMediaDeviceRemovedStopPlay'], isPlay.value, label, prevDeviceLabel)
|
||||
if (
|
||||
appSetting['player.isMediaDeviceRemovedStopPlay'] &&
|
||||
isPlay.value &&
|
||||
label != prevDeviceLabel
|
||||
) {
|
||||
window.lx.isPlayedStop = true
|
||||
pause()
|
||||
if (label != prevDeviceLabel) {
|
||||
window.app_event.playerDeviceChanged()
|
||||
|
||||
if (appSetting['player.isMediaDeviceRemovedStopPlay'] && isPlay.value) {
|
||||
window.lx.isPlayedStop = true
|
||||
pause()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export default () => {
|
||||
const mediaDeviceId = appSetting['player.mediaDeviceId']
|
||||
const device = await getMediaDevice(mediaDeviceId)
|
||||
|
||||
handleDeviceChangeStopPlay(device.label)
|
||||
handleDeviceChange(device.label)
|
||||
|
||||
if (device.deviceId == mediaDeviceId) prevDeviceLabel = device.label
|
||||
else void setMediaDevice(device.deviceId, device.label)
|
||||
|
||||
@@ -32,6 +32,7 @@ import { HOTKEY_PLAYER } from '@common/hotKey'
|
||||
import { playNext, pause, playPrev, togglePlay, collectMusic, uncollectMusic, dislikeMusic } from '@renderer/core/player'
|
||||
import usePlaybackRate from './usePlaybackRate'
|
||||
import useSoundEffect from './useSoundEffect'
|
||||
import useMaxOutputChannelCount from './useMaxOutputChannelCount'
|
||||
import { setPowerSaveBlocker } from '@renderer/core/player/utils'
|
||||
|
||||
|
||||
@@ -43,6 +44,7 @@ export default () => {
|
||||
usePlayEvent()
|
||||
useLyric()
|
||||
useVolume()
|
||||
useMaxOutputChannelCount()
|
||||
useSoundEffect()
|
||||
usePlaybackRate()
|
||||
useWatchList()
|
||||
|
||||
@@ -124,6 +124,10 @@ export class AppEvent extends Event {
|
||||
this.emit('playerWaiting')
|
||||
}
|
||||
|
||||
playerDeviceChanged() {
|
||||
this.emit('playerDeviceChanged')
|
||||
}
|
||||
|
||||
// 激活进度条动画事件
|
||||
activePlayProgressTransition() {
|
||||
this.emit('activePlayProgressTransition')
|
||||
|
||||
@@ -54,6 +54,7 @@ let pitchShifterNode: AudioWorkletNode
|
||||
let pitchShifterNodePitchFactor: AudioParam
|
||||
let pitchShifterNodeLoadStatus: 'none' | 'loading' | 'unconnect' | 'connected' = 'none'
|
||||
let pitchShifterNodeTempValue = 1
|
||||
let defaultChannelCount = 2
|
||||
export const soundR = 0.5
|
||||
|
||||
|
||||
@@ -111,6 +112,7 @@ const initAdvancedAudioFeatures = () => {
|
||||
if (audioContext) return
|
||||
if (!audio) throw new Error('audio not defined')
|
||||
audioContext = new window.AudioContext()
|
||||
defaultChannelCount = audioContext.destination.channelCount
|
||||
|
||||
initAnalyser()
|
||||
initBiquadFilter()
|
||||
@@ -134,6 +136,32 @@ export const getAudioContext = () => {
|
||||
return audioContext
|
||||
}
|
||||
|
||||
let unsubMediaListChangeEvent: (() => void) | null = null
|
||||
export const setMaxOutputChannelCount = (enable: boolean) => {
|
||||
if (enable) {
|
||||
initAdvancedAudioFeatures()
|
||||
audioContext.destination.channelCount = audioContext.destination.maxChannelCount
|
||||
audioContext.destination.channelCountMode = 'max'
|
||||
// navigator.mediaDevices.addEventListener('devicechange', handleMediaListChange)
|
||||
if (!unsubMediaListChangeEvent) {
|
||||
let handleMediaListChange = () => {
|
||||
setMaxOutputChannelCount(true)
|
||||
}
|
||||
window.app_event.on('playerDeviceChanged', handleMediaListChange)
|
||||
unsubMediaListChangeEvent = () => {
|
||||
window.app_event.off('playerDeviceChanged', handleMediaListChange)
|
||||
unsubMediaListChangeEvent = null
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unsubMediaListChangeEvent?.()
|
||||
if (audioContext && audioContext.destination.channelCountMode != 'explicit') {
|
||||
audioContext.destination.channelCount = defaultChannelCount
|
||||
// audioContext.destination.channelInterpretation
|
||||
audioContext.destination.channelCountMode = 'explicit'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const getAnalyser = (): AnalyserNode | null => {
|
||||
initAdvancedAudioFeatures()
|
||||
|
||||
@@ -21,6 +21,8 @@ dd
|
||||
base-checkbox(id="setting_player_lyric_play_lxlrc" :model-value="appSetting['player.isPlayLxlrc']" :label="$t('setting__play_lyric_lxlrc')" @update:model-value="updateSetting({'player.isPlayLxlrc': $event})")
|
||||
.gap-top
|
||||
base-checkbox(id="setting_player_showTaskProgess" :model-value="appSetting['player.isShowTaskProgess']" :label="$t('setting__play_task_bar')" @update:model-value="updateSetting({'player.isShowTaskProgess': $event})")
|
||||
.gap-top
|
||||
base-checkbox(id="setting_player_isMaxOutputChannelCount" :model-value="appSetting['player.isMaxOutputChannelCount']" :label="$t('setting__play_max_output_channel_count')" @update:model-value="updateSetting({'player.isMaxOutputChannelCount': $event})")
|
||||
.gap-top
|
||||
base-checkbox(id="setting_player_isMediaDeviceRemovedStopPlay" :model-value="appSetting['player.isMediaDeviceRemovedStopPlay']" :label="$t('setting__play_mediaDevice_remove_stop_play')" @update:model-value="updateSetting({'player.isMediaDeviceRemovedStopPlay': $event})")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user