DiscordRPC: Added internet radio station support

This commit is contained in:
2026-02-02 15:26:15 +10:00
parent 9f96c574e9
commit 8e7eb4c534
2 changed files with 19 additions and 4 deletions

View File

@@ -60,7 +60,7 @@ static void handleDiscordError(int errcode, const char* message)
}
int discordrpc_init() {
printf("[DiscordRPC] Initializing...\n");
printf("[DiscordRPC] Initializing.\n");
DiscordEventHandlers handlers;
memset(&handlers, 0, sizeof(handlers));
handlers.ready = handleDiscordReady;
@@ -87,7 +87,8 @@ void discordrpc_update(discordrpc_data** discordrpc_struct) {
if ((*discordrpc_struct)->state == DISCORDRPC_STATE_IDLE) {
asprintf(&detailsString, "Idle");
presence.details = detailsString;
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PLAYING) {
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PLAYING_SONG) {
// Playing a song
time_t currentTime = time(NULL);
asprintf(&detailsString, "%s", (*discordrpc_struct)->songTitle);
asprintf(&stateString, "by %s", (*discordrpc_struct)->songArtist);
@@ -99,6 +100,18 @@ void discordrpc_update(discordrpc_data** discordrpc_struct) {
if (configObj->discordrpc_showSysDetails) {
presence.largeImageText = discordrpc_osString;
}
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PLAYING_RADIO) {
// Playing an internet radio station
time_t currentTime = time(NULL);
asprintf(&detailsString, "%s", (*discordrpc_struct)->songTitle);
asprintf(&stateString, "Internet radio station");
presence.details = detailsString;
presence.state = stateString;
presence.largeImageKey = (*discordrpc_struct)->coverArtUrl;
presence.startTimestamp = (long)currentTime;
if (configObj->discordrpc_showSysDetails) {
presence.largeImageText = discordrpc_osString;
}
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PAUSED) {
}