mirror of
https://github.com/Goldenkrew3000/OSSP_OpenSource.git
synced 2026-02-16 12:15:17 +10:00
DiscordRPC: Added internet radio station support
This commit is contained in:
@@ -60,7 +60,7 @@ static void handleDiscordError(int errcode, const char* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int discordrpc_init() {
|
int discordrpc_init() {
|
||||||
printf("[DiscordRPC] Initializing...\n");
|
printf("[DiscordRPC] Initializing.\n");
|
||||||
DiscordEventHandlers handlers;
|
DiscordEventHandlers handlers;
|
||||||
memset(&handlers, 0, sizeof(handlers));
|
memset(&handlers, 0, sizeof(handlers));
|
||||||
handlers.ready = handleDiscordReady;
|
handlers.ready = handleDiscordReady;
|
||||||
@@ -87,7 +87,8 @@ void discordrpc_update(discordrpc_data** discordrpc_struct) {
|
|||||||
if ((*discordrpc_struct)->state == DISCORDRPC_STATE_IDLE) {
|
if ((*discordrpc_struct)->state == DISCORDRPC_STATE_IDLE) {
|
||||||
asprintf(&detailsString, "Idle");
|
asprintf(&detailsString, "Idle");
|
||||||
presence.details = detailsString;
|
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);
|
time_t currentTime = time(NULL);
|
||||||
asprintf(&detailsString, "%s", (*discordrpc_struct)->songTitle);
|
asprintf(&detailsString, "%s", (*discordrpc_struct)->songTitle);
|
||||||
asprintf(&stateString, "by %s", (*discordrpc_struct)->songArtist);
|
asprintf(&stateString, "by %s", (*discordrpc_struct)->songArtist);
|
||||||
@@ -99,6 +100,18 @@ void discordrpc_update(discordrpc_data** discordrpc_struct) {
|
|||||||
if (configObj->discordrpc_showSysDetails) {
|
if (configObj->discordrpc_showSysDetails) {
|
||||||
presence.largeImageText = discordrpc_osString;
|
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) {
|
} else if ((*discordrpc_struct)->state == DISCORDRPC_STATE_PAUSED) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,9 @@
|
|||||||
#define _DISCORDRPC_H
|
#define _DISCORDRPC_H
|
||||||
|
|
||||||
#define DISCORDRPC_STATE_IDLE 0
|
#define DISCORDRPC_STATE_IDLE 0
|
||||||
#define DISCORDRPC_STATE_PLAYING 1
|
#define DISCORDRPC_STATE_PLAYING_SONG 1
|
||||||
#define DISCORDRPC_STATE_PAUSED 2
|
#define DISCORDRPC_STATE_PLAYING_RADIO 2
|
||||||
|
#define DISCORDRPC_STATE_PAUSED 4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int state;
|
int state;
|
||||||
@@ -17,6 +18,7 @@ typedef struct {
|
|||||||
char* songTitle;
|
char* songTitle;
|
||||||
char* songArtist;
|
char* songArtist;
|
||||||
char* coverArtUrl;
|
char* coverArtUrl;
|
||||||
|
int isRadio;
|
||||||
} discordrpc_data;
|
} discordrpc_data;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user