fix mpris

This commit is contained in:
Araxeus
2021-11-10 00:53:44 +02:00
parent f40ed04899
commit ccfe7434bf
5 changed files with 113 additions and 50 deletions

View File

@ -11,9 +11,19 @@ ipcRenderer.on("update-song-info", async (_, extractedSongInfo) => {
module.exports = () => {
document.addEventListener('apiLoaded', e => {
setupTimeChangeListener();
document.querySelector('video').addEventListener('loadedmetadata', () => {
const data = e.detail.getPlayerResponse();
ipcRenderer.send("song-info-request", JSON.stringify(data));
});
}, { once: true, passive: true })
};
function setupTimeChangeListener() {
const progressObserver = new MutationObserver(mutations => {
ipcRenderer.send('timeChanged', mutations[0].target.value);
global.songInfo.elapsedSeconds = mutations[0].target.value;
});
progressObserver.observe(document.querySelector('#progress-bar'), { attributeFilter: ["value"] })
}