feat(api-server): add endpoint to get volume state (#2813)

* add volume getter

* format

* add volume route
This commit is contained in:
Johannes7k75
2025-01-10 04:25:32 +01:00
committed by GitHub
parent fdc798ad87
commit e61757a7fc
3 changed files with 31 additions and 0 deletions

View File

@ -27,6 +27,7 @@ export const backend = createBackend<BackendType, APIServerConfig>({
ctx.ipc.on('ytmd:player-api-loaded', () => {
ctx.ipc.send('ytmd:setup-time-changed-listener');
ctx.ipc.send('ytmd:setup-repeat-changed-listener');
ctx.ipc.send('ytmd:setup-volume-changed-listener');
});
ctx.ipc.on(
@ -34,6 +35,11 @@ export const backend = createBackend<BackendType, APIServerConfig>({
(mode: RepeatMode) => (this.currentRepeatMode = mode),
);
ctx.ipc.on(
'ytmd:volume-changed',
(newVolume: number) => (this.volume = newVolume),
);
this.run(config.hostname, config.port);
},
stop() {
@ -95,6 +101,7 @@ export const backend = createBackend<BackendType, APIServerConfig>({
ctx,
() => this.songInfo,
() => this.currentRepeatMode,
() => this.volume,
);
registerAuth(this.app, ctx);