mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Allow disable listen along (#426)
This commit is contained in:
@ -45,7 +45,8 @@ const defaultConfig = {
|
|||||||
discord: {
|
discord: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
activityTimoutEnabled: true, // if enabled, the discord rich presence gets cleared when music paused after the time specified below
|
activityTimoutEnabled: true, // if enabled, the discord rich presence gets cleared when music paused after the time specified below
|
||||||
activityTimoutTime: 10 * 60 * 1000 // 10 minutes
|
activityTimoutTime: 10 * 60 * 1000, // 10 minutes
|
||||||
|
listenAlong: true, // add a "listen along" button to rich presence
|
||||||
},
|
},
|
||||||
notifications: {
|
notifications: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|||||||
@ -3,6 +3,11 @@ const Store = require("electron-store");
|
|||||||
const defaults = require("./defaults");
|
const defaults = require("./defaults");
|
||||||
|
|
||||||
const migrations = {
|
const migrations = {
|
||||||
|
">=1.13.0": (store) => {
|
||||||
|
if (store.get("plugins.discord.listenAlong") === undefined) {
|
||||||
|
store.set("plugins.discord.listenAlong", true);
|
||||||
|
}
|
||||||
|
},
|
||||||
">=1.11.0": (store) => {
|
">=1.11.0": (store) => {
|
||||||
if (store.get("options.resumeOnStart") === undefined) {
|
if (store.get("options.resumeOnStart") === undefined) {
|
||||||
store.set("options.resumeOnStart", true);
|
store.set("options.resumeOnStart", true);
|
||||||
|
|||||||
@ -70,7 +70,7 @@ let clearActivity;
|
|||||||
*/
|
*/
|
||||||
let updateActivity;
|
let updateActivity;
|
||||||
|
|
||||||
module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
|
module.exports = (win, {activityTimoutEnabled, activityTimoutTime, listenAlong}) => {
|
||||||
window = win;
|
window = win;
|
||||||
// We get multiple events
|
// We get multiple events
|
||||||
// Next song: PAUSE(n), PAUSE(n+1), PLAY(n+1)
|
// Next song: PAUSE(n), PAUSE(n+1), PLAY(n+1)
|
||||||
@ -106,11 +106,11 @@ module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
|
|||||||
largeImageKey: "logo",
|
largeImageKey: "logo",
|
||||||
largeImageText: [
|
largeImageText: [
|
||||||
songInfo.uploadDate,
|
songInfo.uploadDate,
|
||||||
songInfo.views.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " views"
|
songInfo.views.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + " views",
|
||||||
].join(' || '),
|
].join(' || '),
|
||||||
buttons: [
|
buttons: listenAlong ? [
|
||||||
{ label: "Listen Along", url: songInfo.url },
|
{ label: "Listen Along", url: songInfo.url },
|
||||||
],
|
] : undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (songInfo.isPaused) {
|
if (songInfo.isPaused) {
|
||||||
@ -119,7 +119,7 @@ module.exports = (win, {activityTimoutEnabled, activityTimoutTime}) => {
|
|||||||
activityInfo.smallImageText = "idle/paused";
|
activityInfo.smallImageText = "idle/paused";
|
||||||
// Set start the timer so the activity gets cleared after a while if enabled
|
// Set start the timer so the activity gets cleared after a while if enabled
|
||||||
if (activityTimoutEnabled)
|
if (activityTimoutEnabled)
|
||||||
clearActivity = setTimeout(() => info.rpc.clearActivity().catch(console.error), activityTimoutTime || 10000);
|
clearActivity = setTimeout(() => info.rpc.clearActivity().catch(console.error), activityTimoutTime ?? 10000);
|
||||||
} else {
|
} else {
|
||||||
// Add the start and end time of the song
|
// Add the start and end time of the song
|
||||||
const songStartTime = Date.now() - songInfo.elapsedSeconds * 1000;
|
const songStartTime = Date.now() - songInfo.elapsedSeconds * 1000;
|
||||||
|
|||||||
@ -29,6 +29,15 @@ module.exports = (win, options, refreshMenu) => {
|
|||||||
setOptions('discord', options);
|
setOptions('discord', options);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Listen Along",
|
||||||
|
type: "checkbox",
|
||||||
|
checked: options.listenAlong,
|
||||||
|
click: (item) => {
|
||||||
|
options.listenAlong = item.checked;
|
||||||
|
setOptions('discord', options);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Set timeout time in config",
|
label: "Set timeout time in config",
|
||||||
// open config.json
|
// open config.json
|
||||||
|
|||||||
Reference in New Issue
Block a user