mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat: use osdlyrics dbus interface to send lyric contents
This commit is contained in:
parent
845bc8a921
commit
ed1daab1f6
8 changed files with 45 additions and 55 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import dbus from 'dbus-next';
|
||||
import { ipcMain, app } from 'electron';
|
||||
|
||||
export function createMpris(window) {
|
||||
|
|
@ -63,3 +64,26 @@ export function createMpris(window) {
|
|||
player.shuffle = shuffle;
|
||||
});
|
||||
}
|
||||
|
||||
export async function createDbus(window) {
|
||||
const bus = dbus.sessionBus();
|
||||
const Variant = dbus.Variant;
|
||||
|
||||
const osdService = await bus.getProxyObject(
|
||||
'org.osdlyrics.Daemon',
|
||||
'/org/osdlyrics/Lyrics'
|
||||
);
|
||||
|
||||
const osdInterface = osdService.getInterface('org.osdlyrics.Lyrics');
|
||||
|
||||
ipcMain.on('sendLyrics', async (e, { track, lyrics }) => {
|
||||
const metadata = {
|
||||
title: new Variant('s', track.name),
|
||||
artist: new Variant('s', track.ar.map(ar => ar.name).join(', ')),
|
||||
};
|
||||
|
||||
await osdInterface.SetLyricContent(metadata, Buffer.from(lyrics));
|
||||
|
||||
window.webContents.send('saveLyricFinished');
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue