mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-18 21:52:05 +00:00
fix mpris
This commit is contained in:
@ -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"] })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user