mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 19:31:46 +00:00
fix multiple songInfo calls on start
This commit is contained in:
@ -22,21 +22,22 @@ module.exports = () => {
|
|||||||
sendSongInfo();
|
sendSongInfo();
|
||||||
})
|
})
|
||||||
|
|
||||||
video.addEventListener('pause', e => {
|
for (const status of ['playing', 'pause']) {
|
||||||
ipcRenderer.send("playPaused", { isPaused: true, elapsedSeconds: Math.floor(e.target.currentTime) });
|
video.addEventListener(status, e => {
|
||||||
});
|
if (Math.floor(e.target.currentTime) > 0) {
|
||||||
|
ipcRenderer.send("playPaused", {
|
||||||
video.addEventListener('playing', e => {
|
isPaused: status === 'pause',
|
||||||
if (e.target.currentTime > 0){
|
elapsedSeconds: Math.floor(e.target.currentTime)
|
||||||
ipcRenderer.send("playPaused", { isPaused: false, elapsedSeconds: Math.floor(e.target.currentTime) });
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function sendSongInfo() {
|
function sendSongInfo() {
|
||||||
const data = apiEvent.detail.getPlayerResponse();
|
const data = apiEvent.detail.getPlayerResponse();
|
||||||
data.videoDetails.elapsedSeconds = Math.floor(video.currentTime);
|
data.videoDetails.elapsedSeconds = Math.floor(video.currentTime);
|
||||||
data.videoDetails.isPaused = video.paused;
|
data.videoDetails.isPaused = false;
|
||||||
ipcRenderer.send("video-src-changed", JSON.stringify(apiEvent.detail.getPlayerResponse()));
|
ipcRenderer.send("video-src-changed", JSON.stringify(data));
|
||||||
}
|
}
|
||||||
}, { once: true, passive: true });
|
}, { once: true, passive: true });
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user