mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 10:11:46 +00:00
32 lines
713 B
JavaScript
32 lines
713 B
JavaScript
const {Notification} = require('electron');
|
|
|
|
function notify(info) {
|
|
let notificationImage = 'assets/youtube-music.png';
|
|
|
|
if (info.image) {
|
|
notificationImage = info.image.resize({height: 256, width: 256});
|
|
}
|
|
|
|
// Fill the notification with content
|
|
const notification = {
|
|
title: info.title || 'Playing',
|
|
body: info.artist,
|
|
icon: notificationImage,
|
|
silent: true
|
|
};
|
|
// Send the notification
|
|
new Notification(notification).show();
|
|
}
|
|
|
|
module.exports = win => {
|
|
win.on('ready-to-show', () => {
|
|
// Register the callback for new song information
|
|
global.songInfo.onNewData(songInfo => {
|
|
// If song is playing send notification
|
|
if (!songInfo.isPaused) {
|
|
notify(songInfo);
|
|
}
|
|
});
|
|
});
|
|
};
|