Reputation: 201
I am doing spotify streaming in android, using official libspotify.so. Now i can connect to spotify AP, but the status is still not logged in.
Initialise() successfully, callback_notify_main_thread is called
10-26 14:00:05.925: PID:1419, TID:1419 D/MBS: --- Session:Initialise
10-26 14:00:05.935: PID:1419, TID:1419 D/MBS: --- Session:callback_notify_main_thread
10-26 14:00:05.935: PID:1419, TID:1419 D/MBS: --- Session:Initialise:end:0
login() is called "successfully", callback_log_message shows it cannot login offline, the logging status is false
10-26 14:00:05.935: PID:1419, TID:1419 D/MBS: --- Session:login
10-26 14:00:05.935: PID:1419, TID:1419 D/MBS: --- Session:OnLogMessage, data: 11:00:05.943 I [offline_authorizer.cpp:297] Unable to login offline: no such user
10-26 14:00:05.945: PID:1419, TID:1419 D/MBS: --- Session:login:end:0
10-26 14:00:05.945: PID:1419, TID:1419 D/MBS: --- Session:IsLoggedIn:false
More callback_log_messages are coming in different thread
10-26 14:00:05.945: PID:1419, **TID:1427** D/MBS: --- Session:OnLogMessage, data: 11:00:05.951 I [ap:1752] Connecting to AP ap.spotify.com:4070
10-26 14:00:05.965: PID:1419, **TID:1427** D/MBS: --- Session:OnLogMessage, data: 11:00:05.969 I [network.cpp:438] Connecting to 78.31.8.42:4070
10-26 14:00:06.015: PID:1419, **TID:1427** D/MBS: --- Session:OnLogMessage, data: 11:00:06.014 I [ap:1226] Connected to AP: 78.31.8.42:4070
after coonected to spotify ap, logging status is still false, no callback_logged_in is called
10-26 14:33:38.095: PID:1419, TID:1419 D/MBS: --- Session:IsLoggedIn:false
any idea, thanks.
Upvotes: 2
Views: 539
Reputation: 201
need to call sp_session_process_events() in main thread after notify_main_thread. from https://developer.spotify.com/technologies/libspotify/faq/
What is the the notify_main_thread callback? Why is it needed? This callback is invoked from any thread when the main thread need to awaken to process events and in turn deliver callbacks to your application.
then login call back will be called. and check the GetConnectionState(), it is 4. SP_CONNECTION_STATE_OFFLINE = 4 ///< Logged in in offline mode
Upvotes: 3