mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
nit: prettier
This commit is contained in:
@ -1,18 +1,18 @@
|
|||||||
const {Notification} = require('electron');
|
const { Notification } = require("electron");
|
||||||
|
|
||||||
const notify = info => {
|
const notify = info => {
|
||||||
let notificationImage = 'assets/youtube-music.png';
|
let notificationImage = 'assets/youtube-music.png';
|
||||||
|
|
||||||
if (info.image) {
|
if (info.image) {
|
||||||
notificationImage = info.image.resize({height: 256, width: 256});
|
notificationImage = info.image.resize({ height: 256, width: 256 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill the notification with content
|
// Fill the notification with content
|
||||||
const notification = {
|
const notification = {
|
||||||
title: info.title || 'Playing',
|
title: info.title || "Playing",
|
||||||
body: info.artist,
|
body: info.artist,
|
||||||
icon: notificationImage,
|
icon: notificationImage,
|
||||||
silent: true
|
silent: true,
|
||||||
};
|
};
|
||||||
// Send the notification
|
// Send the notification
|
||||||
new Notification(notification).show();
|
new Notification(notification).show();
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
const {TouchBar} = require('electron');
|
const { TouchBar } = require("electron");
|
||||||
const {
|
const {
|
||||||
TouchBarButton,
|
TouchBarButton,
|
||||||
TouchBarLabel,
|
TouchBarLabel,
|
||||||
TouchBarSpacer,
|
TouchBarSpacer,
|
||||||
TouchBarSegmentedControl,
|
TouchBarSegmentedControl,
|
||||||
TouchBarScrubber
|
TouchBarScrubber,
|
||||||
} = TouchBar;
|
} = TouchBar;
|
||||||
|
|
||||||
// Songtitle label
|
// Songtitle label
|
||||||
const songTitle = new TouchBarLabel({
|
const songTitle = new TouchBarLabel({
|
||||||
label: ''
|
label: "",
|
||||||
});
|
});
|
||||||
// This will store the song controls once available
|
// This will store the song controls once available
|
||||||
let controls = [];
|
let controls = [];
|
||||||
@ -22,23 +22,23 @@ const pausePlayButton = new TouchBarButton();
|
|||||||
|
|
||||||
// The song control buttons (control functions are in the same order)
|
// The song control buttons (control functions are in the same order)
|
||||||
const buttons = new TouchBarSegmentedControl({
|
const buttons = new TouchBarSegmentedControl({
|
||||||
mode: 'buttons',
|
mode: "buttons",
|
||||||
segments: [
|
segments: [
|
||||||
new TouchBarButton({
|
new TouchBarButton({
|
||||||
label: '⏮'
|
label: "⏮",
|
||||||
}),
|
}),
|
||||||
pausePlayButton,
|
pausePlayButton,
|
||||||
new TouchBarButton({
|
new TouchBarButton({
|
||||||
label: '⏭'
|
label: "⏭",
|
||||||
}),
|
}),
|
||||||
new TouchBarButton({
|
new TouchBarButton({
|
||||||
label: '👎'
|
label: "👎",
|
||||||
}),
|
}),
|
||||||
new TouchBarButton({
|
new TouchBarButton({
|
||||||
label: '👍'
|
label: "👍",
|
||||||
})
|
}),
|
||||||
],
|
],
|
||||||
change: i => controls[i]()
|
change: (i) => controls[i](),
|
||||||
});
|
});
|
||||||
|
|
||||||
// This is the touchbar object, this combines everything with proper layout
|
// This is the touchbar object, this combines everything with proper layout
|
||||||
@ -46,13 +46,13 @@ const touchBar = new TouchBar({
|
|||||||
items: [
|
items: [
|
||||||
new TouchBarScrubber({
|
new TouchBarScrubber({
|
||||||
items: [songImage, songTitle],
|
items: [songImage, songTitle],
|
||||||
continuous: false
|
continuous: false,
|
||||||
}),
|
}),
|
||||||
new TouchBarSpacer({
|
new TouchBarSpacer({
|
||||||
size: 'flexible'
|
size: "flexible",
|
||||||
}),
|
}),
|
||||||
buttons
|
buttons,
|
||||||
]
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = win => {
|
module.exports = win => {
|
||||||
@ -74,10 +74,12 @@ module.exports = win => {
|
|||||||
songTitle.label = songInfo.title;
|
songTitle.label = songInfo.title;
|
||||||
|
|
||||||
// Changes the pause button if paused
|
// Changes the pause button if paused
|
||||||
pausePlayButton.label = songInfo.isPaused ? '▶️' : '⏸';
|
pausePlayButton.label = songInfo.isPaused ? "▶️" : "⏸";
|
||||||
|
|
||||||
// Get image source
|
// Get image source
|
||||||
songImage.icon = songInfo.image ? songInfo.image.resize({height: 23}) : null;
|
songImage.icon = songInfo.image
|
||||||
|
? songInfo.image.resize({ height: 23 })
|
||||||
|
: null;
|
||||||
|
|
||||||
win.setTouchBar(touchBar);
|
win.setTouchBar(touchBar);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user