feat: reworked the api, added duration/current in seconds + shuffle & repeat

This commit is contained in:
2024-05-05 20:12:10 +02:00
parent 000853414e
commit db8a2c2741
15 changed files with 199 additions and 94 deletions

View File

@@ -12,6 +12,7 @@ import { StoreData } from "./features/listenbrainz/models/storeData";
import { Logger } from "./features/logger";
import { Songwhip } from "./features/songwhip/songwhip";
import { addCustomCss } from "./features/theming/theming";
import { convertDurationToSeconds } from "./features/time/parse";
import { MediaStatus } from "./models/mediaStatus";
import { Options } from "./models/options";
import { downloadFile } from "./scripts/download";
@@ -318,6 +319,12 @@ function addIPCEventListeners() {
case globalEvents.toggleFavorite:
elements.click("favorite");
break;
case globalEvents.toggleShuffle:
elements.click("shuffle");
break;
case globalEvents.toggleRepeat:
elements.click("repeat");
break;
default:
break;
}
@@ -523,7 +530,9 @@ setInterval(function () {
status: currentStatus,
url: getTrackURL(),
current,
currentInSeconds: convertDurationToSeconds(current),
duration,
durationInSeconds: convertDurationToSeconds(duration),
"app-name": appName,
image: "",
icon: "",
@@ -560,7 +569,10 @@ setInterval(function () {
});
} else {
// just update the time
updateMediaInfo({ ...currentMediaInfo, ...{ current } }, false);
updateMediaInfo(
{ ...currentMediaInfo, ...{ current, currentInSeconds: convertDurationToSeconds(current) } },
false
);
}
/**