• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by johnm212 · Dec 21, 2017 at 04:00 PM · threadsthreadingthread

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ShadyProductions · Dec 22, 2017 at 02:26 PM 0
Share

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();
     }

2 Replies

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

73 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What does new Thread do, and how many threads are too many? 1 Answer

will monobehaviour stay alive after DOTS? 0 Answers

LobbyHook doesn't give clients variables 0 Answers

Return value from coroutine to non monobehaviour 1 Answer

How to prevent heavy method calculation from locking Unity up? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges