Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <despotify.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- void callback(struct despotify_session *ds, int signal, void *data,
- void *callback_data) {
- (void)ds; (void)callback_data;
- }
- int main (int argc, char **argv) {
- char *username = "SETME";
- char *password = "SETME";
- char *track_id = "7b9851ed4ec54358a4712c6764ac0a5f";
- if(!despotify_init()) {
- fprintf(stderr, "Failed to initialise despotify.\n");
- return 1;
- }
- struct despotify_session *ds = despotify_init_client(callback, NULL, true, false);
- if(!ds) {
- fprintf(stderr, "Failed to initialise despotify client.\n");
- return 1;
- }
- if(!despotify_authenticate(ds, username, password)) {
- printf("Authentication failed: %s\n", despotify_get_error(ds));
- return 1;
- }
- struct track *track = despotify_get_track(ds, track_id);
- if(!track) {
- printf("No such track.\n");
- return 1;
- }
- if(!despotify_play(ds, track, 1)) {
- printf("Failed to start playback.\n");
- return 1;
- }
- printf("Track playing... (blocking...)\n");
- while (1) {
- usleep(100000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement