mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-15 12:21:47 +00:00
small refactor
This commit is contained in:
@ -8,26 +8,24 @@ let currentSongInfo;
|
|||||||
module.exports = win => {
|
module.exports = win => {
|
||||||
const registerCallback = getSongInfo(win);
|
const registerCallback = getSongInfo(win);
|
||||||
const { playPause, next, previous } = getSongControls(win);
|
const { playPause, next, previous } = getSongControls(win);
|
||||||
controls = { playPause, next, previous }
|
controls = { playPause, next, previous };
|
||||||
|
|
||||||
registerCallback(songInfo => {
|
registerCallback(songInfo => {
|
||||||
//update currentsonginfo for win.on('show')
|
//update currentsonginfo for win.on('show')
|
||||||
currentSongInfo = songInfo;
|
currentSongInfo = songInfo;
|
||||||
// update thumbar
|
// update thumbar
|
||||||
setThumbar(win, songInfo)
|
setThumbar(win, songInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
// need to set thumbar again after win.show
|
// need to set thumbar again after win.show
|
||||||
win.on("show", () => {
|
win.on("show", () => {
|
||||||
if (currentSongInfo) {
|
setThumbar(win, currentSongInfo)
|
||||||
setThumbar(win, currentSongInfo)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
function setThumbar(win, songInfo) {
|
function setThumbar(win, songInfo) {
|
||||||
// Wait for song to start before setting thumbar
|
// Wait for song to start before setting thumbar
|
||||||
if (!songInfo.title) {
|
if (!songInfo?.title) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user