mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
Merge pull request #802 from amsyarasyiq/master
proposal: Adding an option to hide duration before the song ends
This commit is contained in:
@ -49,6 +49,7 @@ const defaultConfig = {
|
|||||||
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
|
listenAlong: true, // add a "listen along" button to rich presence
|
||||||
|
hideDurationLeft: false, // hides the start and end time of the song to rich presence
|
||||||
},
|
},
|
||||||
notifications: {
|
notifications: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
|||||||
@ -70,7 +70,7 @@ let clearActivity;
|
|||||||
*/
|
*/
|
||||||
let updateActivity;
|
let updateActivity;
|
||||||
|
|
||||||
module.exports = (win, { activityTimoutEnabled, activityTimoutTime, listenAlong }) => {
|
module.exports = (win, { activityTimoutEnabled, activityTimoutTime, listenAlong, hideDurationLeft }) => {
|
||||||
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)
|
||||||
@ -117,7 +117,7 @@ module.exports = (win, { activityTimoutEnabled, activityTimoutTime, listenAlong
|
|||||||
// 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 if (!hideDurationLeft) {
|
||||||
// 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;
|
||||||
activityInfo.startTimestamp = songStartTime;
|
activityInfo.startTimestamp = songStartTime;
|
||||||
|
|||||||
@ -40,6 +40,15 @@ module.exports = (win, options, refreshMenu) => {
|
|||||||
setMenuOptions('discord', options);
|
setMenuOptions('discord', options);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: "Hide duration left",
|
||||||
|
type: "checkbox",
|
||||||
|
checked: options.hideDurationLeft,
|
||||||
|
click: (item) => {
|
||||||
|
options.hideDurationLeft = item.checked;
|
||||||
|
setMenuOptions('discord', options);
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: "Set inactivity timeout",
|
label: "Set inactivity timeout",
|
||||||
click: () => setInactivityTimeout(win, options),
|
click: () => setInactivityTimeout(win, options),
|
||||||
|
|||||||
Reference in New Issue
Block a user