mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
add MPRIS volume handler (#1415)
This commit is contained in:
@@ -657,6 +657,9 @@ if (mprisPlayer) {
|
|||||||
}
|
}
|
||||||
currentState.volume = volume;
|
currentState.volume = volume;
|
||||||
broadcast({ data: volume, event: 'volume' });
|
broadcast({ data: volume, event: 'volume' });
|
||||||
|
getMainWindow()?.webContents.send('request-volume', {
|
||||||
|
volume,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,11 +51,16 @@ const requestToggleShuffle = (
|
|||||||
ipcRenderer.on('mpris-request-toggle-shuffle', cb);
|
ipcRenderer.on('mpris-request-toggle-shuffle', cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const requestVolume = (cb: (event: IpcRendererEvent, data: { volume: number }) => void) => {
|
||||||
|
ipcRenderer.on('request-volume', cb);
|
||||||
|
};
|
||||||
|
|
||||||
export const mpris = {
|
export const mpris = {
|
||||||
requestPosition,
|
requestPosition,
|
||||||
requestSeek,
|
requestSeek,
|
||||||
requestToggleRepeat,
|
requestToggleRepeat,
|
||||||
requestToggleShuffle,
|
requestToggleShuffle,
|
||||||
|
requestVolume,
|
||||||
updatePosition,
|
updatePosition,
|
||||||
updateRepeat,
|
updateRepeat,
|
||||||
updateSeek,
|
updateSeek,
|
||||||
|
|||||||
@@ -43,11 +43,16 @@ export const useMPRIS = () => {
|
|||||||
player.toggleShuffle();
|
player.toggleShuffle();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mpris?.requestVolume((_e: unknown, data: { volume: number }) => {
|
||||||
|
player.setVolume(data.volume);
|
||||||
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
ipc?.removeAllListeners('mpris-request-toggle-repeat');
|
ipc?.removeAllListeners('mpris-request-toggle-repeat');
|
||||||
ipc?.removeAllListeners('mpris-request-toggle-shuffle');
|
ipc?.removeAllListeners('mpris-request-toggle-shuffle');
|
||||||
ipc?.removeAllListeners('request-position');
|
ipc?.removeAllListeners('request-position');
|
||||||
ipc?.removeAllListeners('request-seek');
|
ipc?.removeAllListeners('request-seek');
|
||||||
|
ipc?.removeAllListeners('request-volume');
|
||||||
};
|
};
|
||||||
}, [player]);
|
}, [player]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user