show toolbar if a player is loaded

This commit is contained in:
SrGooglo 2025-04-09 14:16:00 +00:00
parent 92b5bad7ec
commit 2225083995

View File

@ -1,261 +1,270 @@
import loadable from "@loadable/component" import loadable from "@loadable/component"
export default { export default {
id: "player", id: "player",
icon: "PlayCircleOutlined", icon: "PlayCircleOutlined",
label: "Player", label: "Player",
group: "app", group: "app",
settings: [ onLoad: () => {
{ if (app.cores.player.state.track_manifest && app.layout.tools_bar) {
id: "player.gain", app.layout.tools_bar.toggleVisibility(true)
title: "Gain", }
icon: "MdGraphicEq", },
group: "general", settings: [
description: "Adjust gain for audio output", {
component: "Slider", id: "player.gain",
props: { title: "Gain",
min: 1, icon: "MdGraphicEq",
max: 2, group: "general",
step: 0.1, description: "Adjust gain for audio output",
marks: { component: "Slider",
1: "Normal", props: {
1.5: "+50%", min: 1,
2: "+100%" max: 2,
} step: 0.1,
}, marks: {
defaultValue: () => { 1: "Normal",
return app.cores.player.gain.values().gain 1.5: "+50%",
}, 2: "+100%",
onUpdate: (value) => { },
app.cores.player.gain.modifyValues({ },
gain: value defaultValue: () => {
}) return app.cores.player.gain.values().gain
}, },
storaged: false, onUpdate: (value) => {
}, app.cores.player.gain.modifyValues({
{ gain: value,
id: "player.sample_rate", })
title: "Sample Rate", },
icon: "MdHearing", storaged: false,
group: "general", },
description: "Internal sample rate for audio output", {
component: "Select", id: "player.sample_rate",
props: { title: "Sample Rate",
options: [ icon: "MdHearing",
{ group: "general",
value: 44100, description: "Internal sample rate for audio output",
label: "44100 Hz" component: "Select",
}, props: {
{ options: [
value: 48000, {
label: "48000 Hz" value: 44100,
}, label: "44100 Hz",
{ },
value: 96000, {
label: "96000 Hz" value: 48000,
}, label: "48000 Hz",
{ },
value: 192000, {
label: "192000 Hz" value: 96000,
} label: "96000 Hz",
] },
}, {
defaultValue: (ctx) => { value: 192000,
return app.cores.player.audioContext.sampleRate label: "192000 Hz",
}, },
onUpdate: async (value) => { ],
const sampleRate = await app.cores.player.controls.setSampleRate(value) },
defaultValue: (ctx) => {
return app.cores.player.audioContext.sampleRate
},
onUpdate: async (value) => {
const sampleRate =
await app.cores.player.controls.setSampleRate(value)
return sampleRate return sampleRate
}, },
storaged: false, storaged: false,
}, },
{ {
id: "player.compressor.values", id: "player.compressor.values",
title: "Compression", title: "Compression",
icon: "FiSliders", icon: "FiSliders",
group: "general", group: "general",
description: "Adjust compression values (Warning: may cause distortion when changing values)", description:
experimental: true, "Adjust compression values (Warning: may cause distortion when changing values)",
dependsOn: { experimental: true,
"player.compressor": true dependsOn: {
}, "player.compressor": true,
component: loadable(() => import("./items/player.compressor")), },
switchDefault: () => { component: loadable(() => import("./items/player.compressor")),
return app.cores.settings.get("player.compressor") switchDefault: () => {
}, return app.cores.settings.get("player.compressor")
onEnabledChange: (enabled) => { },
if (enabled === true) { onEnabledChange: (enabled) => {
app.cores.settings.set("player.compressor", true) if (enabled === true) {
app.cores.player.compressor.attach() app.cores.settings.set("player.compressor", true)
} else { app.cores.player.compressor.attach()
app.cores.settings.set("player.compressor", false) } else {
app.cores.player.compressor.detach() app.cores.settings.set("player.compressor", false)
} app.cores.player.compressor.detach()
}, }
extraActions: [ },
{ extraActions: [
id: "reset", {
title: "Default", id: "reset",
icon: "MdRefresh", title: "Default",
onClick: async (ctx) => { icon: "MdRefresh",
const values = await app.cores.player.compressor.presets.setCurrentPresetToDefault() onClick: async (ctx) => {
const values =
await app.cores.player.compressor.presets.setCurrentPresetToDefault()
ctx.updateCurrentValue(values) ctx.updateCurrentValue(values)
} },
} },
], ],
props: { props: {
valueFormat: (value) => `${value}dB`, valueFormat: (value) => `${value}dB`,
sliders: [ sliders: [
{ {
key: "threshold", key: "threshold",
label: "Threshold", label: "Threshold",
min: -100, min: -100,
max: 0, max: 0,
}, },
{ {
key: "knee", key: "knee",
label: "Knee", label: "Knee",
min: 0, min: 0,
max: 40, max: 40,
}, },
{ {
key: "ratio", key: "ratio",
label: "Ratio", label: "Ratio",
min: 1, min: 1,
max: 20, max: 20,
valueFormat: (value) => `${value}:1`, valueFormat: (value) => `${value}:1`,
}, },
{ {
key: "attack", key: "attack",
label: "Attack", label: "Attack",
min: 0, min: 0,
max: 1, max: 1,
valueFormat: (value) => `${value} s`, valueFormat: (value) => `${value} s`,
}, },
{ {
key: "release", key: "release",
label: "Release", label: "Release",
min: 0, min: 0,
max: 1, max: 1,
valueFormat: (value) => `${value} s`, valueFormat: (value) => `${value} s`,
}, },
], ],
}, },
onUpdate: (value) => { onUpdate: (value) => {
app.cores.player.compressor.presets.setToCurrent(value) app.cores.player.compressor.presets.setToCurrent(value)
return value return value
}, },
storaged: false, storaged: false,
}, },
{ {
id: "player.eq", id: "player.eq",
title: "Equalizer", title: "Equalizer",
group: "general", group: "general",
icon: "MdGraphicEq", icon: "MdGraphicEq",
description: "Enable equalizer for audio output", description: "Enable equalizer for audio output",
component: loadable(() => import("./items/player.eq")), component: loadable(() => import("./items/player.eq")),
extraActions: [ extraActions: [
{ {
id: "reset", id: "reset",
title: "Reset", title: "Reset",
icon: "MdRefresh", icon: "MdRefresh",
onClick: (ctx) => { onClick: (ctx) => {
const values = app.cores.player.eq.presets.setCurrentPresetToDefault() const values =
app.cores.player.eq.presets.setCurrentPresetToDefault()
ctx.updateCurrentValue(values) ctx.updateCurrentValue(values)
} },
}, },
], ],
// dependsOn: { // dependsOn: {
// "player.equalizer": true // "player.equalizer": true
// }, // },
props: { props: {
valueFormat: (value) => `${value}dB`, valueFormat: (value) => `${value}dB`,
marks: [ marks: [
{ {
value: 0, value: 0,
} },
], ],
step: 0.5, step: 0.5,
sliders: [ sliders: [
{ {
key: 32, key: 32,
label: "32", label: "32",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 64, key: 64,
label: "64", label: "64",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 125, key: 125,
label: "125", label: "125",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 250, key: 250,
label: "250", label: "250",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 500, key: 500,
label: "500", label: "500",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 1000, key: 1000,
label: "1K", label: "1K",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 2000, key: 2000,
label: "2K", label: "2K",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 4000, key: 4000,
label: "4K", label: "4K",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 8000, key: 8000,
label: "8K", label: "8K",
max: 10, max: 10,
min: -10, min: -10,
}, },
{ {
key: 16000, key: 16000,
label: "16K", label: "16K",
max: 10, max: 10,
min: -10, min: -10,
} },
] ],
}, },
onUpdate: (value) => { onUpdate: (value) => {
const values = Object.keys(value).reduce((acc, key) => { const values = Object.keys(value).reduce((acc, key) => {
acc[key] = value[key] acc[key] = value[key]
return acc return acc
}, {}) }, {})
app.cores.player.eq.presets.setToCurrent(values) app.cores.player.eq.presets.setToCurrent(values)
return value return value
}, },
storaged: false storaged: false,
} },
] ],
} }