- Home /
Making calls to Spotify REST API blocks main thread
I am making calls to the Spotify REST API https://developer.spotify.com/web-api/ to play/pause playback using this C# wrapper https://github.com/JohnnyCrazy/SpotifyAPI-NET
When I make the calls it blocks the main thread. I have tried putting the calls in co-routines, or using separate threads for them, but neither seem to work. Heres an example of a call to resume playback
public void resumePlayback(){
ErrorResponse error = _spotify.ResumePlayback(context.Device.Id);
}
Thanks in advance
well calling it on a new thread should fix this no?
public void resumePlayback()
{
new System.Threading.Thread(() =>
{
ErrorResponse error = _spotify.ResumePlayback(context.Device.Id);
}).Start();
}
Answer by WelchCompositions · Sep 12, 2018 at 08:14 PM
@johnm212 Would you be open to sharing your implementation of that wrapper into Unity? I've been hacking at it but having some trouble.
Answer by jdnichollsc · May 26, 2019 at 12:12 AM
It would be better using a Rest Client to call the endpoints of any API, try this approach using Promises to handle issues in a better way too => https://github.com/proyecto26/RestClient