Add custom volume step (#2594)

This commit is contained in:
the1812 2023-11-19 19:09:37 +08:00
parent 24b8282c2f
commit fd5d07160a
2 changed files with 11 additions and 2 deletions

View File

@ -82,7 +82,8 @@ export const builtInActions: Record<string, KeyBindingAction> = {
volumeUp: { volumeUp: {
displayName: '增加音量', displayName: '增加音量',
run: () => { run: () => {
const volume = playerAgent.changeVolume(10) const step = getComponentSettings<Options>('keymap').options.volumeStep
const volume = playerAgent.changeVolume(step)
if (lodash.isNil(volume)) { if (lodash.isNil(volume)) {
return volume return volume
} }
@ -93,7 +94,8 @@ export const builtInActions: Record<string, KeyBindingAction> = {
volumeDown: { volumeDown: {
displayName: '降低音量', displayName: '降低音量',
run: () => { run: () => {
const volume = playerAgent.changeVolume(-10) const step = getComponentSettings<Options>('keymap').options.volumeStep
const volume = playerAgent.changeVolume(-step)
if (lodash.isNil(volume)) { if (lodash.isNil(volume)) {
return volume return volume
} }

View File

@ -9,11 +9,18 @@ import { addComponentListener } from '@/core/settings'
import { actions } from './actions' import { actions } from './actions'
import { KeyBinding, KeyBindingConfig, loadKeyBindings } from './bindings' import { KeyBinding, KeyBindingConfig, loadKeyBindings } from './bindings'
import { presetBase, presets } from './presets' import { presetBase, presets } from './presets'
import { getNumberValidator } from '@/core/utils'
const options = defineOptionsMetadata({ const options = defineOptionsMetadata({
longJumpSeconds: { longJumpSeconds: {
defaultValue: 85, defaultValue: 85,
displayName: '长跳跃秒数', displayName: '长跳跃秒数',
validator: getNumberValidator(1),
},
volumeStep: {
defaultValue: 10,
displayName: '音量调整幅度',
validator: getNumberValidator(1, 100),
}, },
customKeyBindings: { customKeyBindings: {
defaultValue: {} as Record<string, string>, defaultValue: {} as Record<string, string>,