mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Merge pull request #10 from Araxeus/Download-Plugin-Directory-Chooser
Download plugin directory chooser
This commit is contained in:
@ -9,6 +9,8 @@ const ytpl = require("ytpl");
|
||||
const { sendError } = require("./back");
|
||||
const { defaultMenuDownloadLabel, getFolder } = require("./utils");
|
||||
|
||||
const { setOptions } = require('../../config/plugins')
|
||||
const { dialog } = require('electron');
|
||||
let downloadLabel = defaultMenuDownloadLabel;
|
||||
|
||||
module.exports = (win, options, refreshMenu) => [
|
||||
@ -60,4 +62,17 @@ module.exports = (win, options, refreshMenu) => [
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Choose download folder:',
|
||||
click: () => {
|
||||
let result = dialog.showOpenDialogSync({
|
||||
properties: ['openDirectory', 'createDirectory'],
|
||||
defaultPath: Array.isArray(options.downloadFolder) ? options.downloadFolder[0] : undefined,
|
||||
})
|
||||
if(result) {
|
||||
options.downloadFolder = result
|
||||
setOptions("downloader", options)
|
||||
} //else = user pressed cancel
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
BIN
plugins/taskbar-mediacontrol/assets/backward.png
Normal file
BIN
plugins/taskbar-mediacontrol/assets/backward.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 269 B |
BIN
plugins/taskbar-mediacontrol/assets/forward.png
Normal file
BIN
plugins/taskbar-mediacontrol/assets/forward.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 250 B |
BIN
plugins/taskbar-mediacontrol/assets/pause.png
Normal file
BIN
plugins/taskbar-mediacontrol/assets/pause.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 192 B |
BIN
plugins/taskbar-mediacontrol/assets/play.png
Normal file
BIN
plugins/taskbar-mediacontrol/assets/play.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 265 B |
58
plugins/taskbar-mediacontrol/back.js
Normal file
58
plugins/taskbar-mediacontrol/back.js
Normal file
@ -0,0 +1,58 @@
|
||||
const getSongControls = require('../../providers/song-controls');
|
||||
const getSongInfo = require('../../providers/song-info');
|
||||
const path = require('path');
|
||||
|
||||
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 {playPause, next, previous} = getSongControls(win);
|
||||
|
||||
// If the page is ready, register the callback
|
||||
win.on('ready-to-show', () => {
|
||||
registerCallback(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() {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);}
|
||||
}
|
||||
]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
// Util
|
||||
function get(file) {
|
||||
return path.join(__dirname,"assets", file);
|
||||
}
|
||||
Reference in New Issue
Block a user