Advertisement
Guest User

Untitled

a guest
May 5th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. #include <despotify.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <unistd.h>
  5.  
  6. void callback(struct despotify_session *ds, int signal, void *data,
  7.               void *callback_data) {
  8.      (void)ds; (void)callback_data;
  9. }
  10.  
  11. int main (int argc, char **argv) {
  12.     char *username = "SETME";
  13.     char *password = "SETME";
  14.     char *track_id = "7b9851ed4ec54358a4712c6764ac0a5f";
  15.  
  16.     if(!despotify_init()) {
  17.         fprintf(stderr, "Failed to initialise despotify.\n");
  18.         return 1;
  19.     }
  20.  
  21.     struct despotify_session *ds = despotify_init_client(callback, NULL, true, false);
  22.     if(!ds) {
  23.         fprintf(stderr, "Failed to initialise despotify client.\n");
  24.         return 1;
  25.     }
  26.  
  27.     if(!despotify_authenticate(ds, username, password)) {
  28.         printf("Authentication failed: %s\n", despotify_get_error(ds));
  29.         return 1;
  30.     }
  31.  
  32.     struct track *track = despotify_get_track(ds, track_id);
  33.  
  34.     if(!track) {
  35.         printf("No such track.\n");
  36.         return 1;
  37.     }
  38.  
  39.     if(!despotify_play(ds, track, 1)) {
  40.         printf("Failed to start playback.\n");
  41.         return 1;
  42.     }
  43.    
  44.     printf("Track playing... (blocking...)\n");
  45.    
  46.     while (1) {
  47.         usleep(100000);
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement