mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
resolve merge conflict
This commit is contained in:
@ -2,57 +2,53 @@ const getSongControls = require('../../providers/song-controls');
|
|||||||
const getSongInfo = require('../../providers/song-info');
|
const getSongInfo = require('../../providers/song-info');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
let controls;
|
||||||
|
let currentSongInfo;
|
||||||
|
|
||||||
module.exports = win => {
|
module.exports = win => {
|
||||||
win.hide = function () {
|
|
||||||
win.minimize();
|
|
||||||
win.setSkipTaskbar(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const show = win.show;
|
|
||||||
win.show = function () {
|
|
||||||
win.restore();
|
|
||||||
win.focus();
|
|
||||||
win.setSkipTaskbar(false);
|
|
||||||
show.apply(win);
|
|
||||||
};
|
|
||||||
|
|
||||||
win.isVisible = function () {
|
|
||||||
return !win.isMinimized();
|
|
||||||
};
|
|
||||||
|
|
||||||
const registerCallback = getSongInfo(win);
|
const registerCallback = getSongInfo(win);
|
||||||
const {playPause, next, previous} = getSongControls(win);
|
const { playPause, next, previous } = getSongControls(win);
|
||||||
|
controls = { playPause, next, previous };
|
||||||
|
|
||||||
// If the page is ready, register the callback
|
registerCallback(songInfo => {
|
||||||
win.once('ready-to-show', () => {
|
//update currentsonginfo for win.on('show')
|
||||||
registerCallback(songInfo => {
|
currentSongInfo = songInfo;
|
||||||
// Wait for song to start before setting thumbar
|
// update thumbar
|
||||||
if (songInfo.title === '') {
|
setThumbar(win, songInfo);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Win32 require full rewrite of components
|
|
||||||
win.setThumbarButtons([
|
|
||||||
{
|
|
||||||
tooltip: 'Previous',
|
|
||||||
icon: get('backward.png'),
|
|
||||||
click() {previous(win.webContents);}
|
|
||||||
}, {
|
|
||||||
tooltip: 'Play/Pause',
|
|
||||||
// Update icon based on play state
|
|
||||||
icon: songInfo.isPaused ? get('play.png') : get('pause.png'),
|
|
||||||
click() {playPause(win.webContents);}
|
|
||||||
}, {
|
|
||||||
tooltip: 'Next',
|
|
||||||
icon: get('forward.png'),
|
|
||||||
click() {next(win.webContents);}
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// need to set thumbar again after win.show
|
||||||
|
win.on("show", () => {
|
||||||
|
setThumbar(win, currentSongInfo)
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function setThumbar(win, songInfo) {
|
||||||
|
// Wait for song to start before setting thumbar
|
||||||
|
if (!songInfo?.title) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Win32 require full rewrite of components
|
||||||
|
win.setThumbarButtons([
|
||||||
|
{
|
||||||
|
tooltip: 'Previous',
|
||||||
|
icon: get('backward.png'),
|
||||||
|
click() { controls.previous(win.webContents); }
|
||||||
|
}, {
|
||||||
|
tooltip: 'Play/Pause',
|
||||||
|
// Update icon based on play state
|
||||||
|
icon: songInfo.isPaused ? get('play.png') : get('pause.png'),
|
||||||
|
click() { controls.playPause(win.webContents); }
|
||||||
|
}, {
|
||||||
|
tooltip: 'Next',
|
||||||
|
icon: get('forward.png'),
|
||||||
|
click() { controls.next(win.webContents); }
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
// Util
|
// Util
|
||||||
function get(file) {
|
function get(file) {
|
||||||
return path.join(__dirname,"assets", file);
|
return path.join(__dirname, "assets", file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user