Advertisement
Guest User

soundcloud music player

a guest
Jan 1st, 2015
658
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.55 KB | None | 0 0
  1. #define WEBSITE_URL "127.0.0.1"
  2.  
  3. #define DIALOG_MUSICPLAYER  (2205)
  4.  
  5. #include <a_samp>
  6. #include <a_http>
  7. #include <sscanf2>
  8. forward MusicResponse(index, response_code, data[]);
  9. public OnFilterScriptInit()
  10. {
  11.     print("Music player loaded");
  12. }
  13.  
  14. public OnPlayerCommandText(playerid, cmdtext[])
  15. {
  16.     if(!strcmp(cmdtext, "/musicplayer", true))
  17.     {
  18.         ShowPlayerDialog(playerid, DIALOG_MUSICPLAYER, DIALOG_STYLE_INPUT, "Music Player", "Please enter url\nCurrent support : soundclound ( only single song, not playlist )", "Listen", "Cancel");
  19.         return 1;
  20.     }
  21.     return 0;
  22. }
  23.  
  24. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  25. {
  26.     if(dialogid == DIALOG_MUSICPLAYER)
  27.     {
  28.         if(response)
  29.         {
  30.             new str[255];
  31.             format(str, sizeof str, "%s/getmusic.php?url=%s", WEBSITE_URL, inputtext);
  32.             printf(str);
  33.             HTTP(playerid, HTTP_GET, str, "", "MusicResponse");
  34.         }
  35.     }
  36.     return 1;
  37. }
  38. public MusicResponse(index, response_code, data[])
  39. {
  40.     if(response_code == 200) //Did the request succeed?
  41.     {
  42.         new result[4][128], str[128];
  43.         printf("data : %s", data);
  44.         if(sscanf(data, "p<,>s[32]s[32]s[32]s[32]", result[0], result[1], result[2], result[3])) return SendClientMessage(index, -1, "Something wrong ");
  45.         format(str, sizeof str, "Current Play: %s - Uploader: %s - Genre: %s", result[0], result[1], result[2]);
  46.         SendClientMessage(index, -1, str);
  47.         PlayAudioStreamForPlayer(index, result[3]);
  48.        
  49.     }
  50.     else
  51.     {
  52.         SendClientMessage(index, -1, "Website down !");
  53.     }
  54.     return 1;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement