问题
I'm writing a NDK wrapper around libspotify on Android. But sp_session_callbacks:: logged_in callback never called.
This is content of tracefile:
libspotify trace from 12.1.51.g86c92b43 Release Android-arm
< sp_session_create() = 0
> sp_session_login(0x240ea8 'moodstream1@gmail.com' '<hidden>' 0) on 0x400fc4c8
This is a log received with sp_session_callbacks:: log_message callback.
13:30:07.361 I [offline_authorizer.cpp:297] Unable to login offline: no such user
13:30:07.372 I [ap:1752] Connecting to AP ap.spotify.com:4070
13:30:07.382 I [network.cpp:438] Connecting to 193.182.8.10:4070
13:30:07.526 I [ap:1226] Connected to AP: 193.182.8.10:4070
As you see session was created correctly.
I've tested on real devices and emulator. The result is the same. Any ideas?
回答1:
The problem could be that they are not driving libspotify properly. This is one of the common problems that people have.
Specifically it is important to listen to the notify_main_thread callback. This indicates that libspotify needs to process some data from the GUI main thread.
sp_session_process_events should then be called from the GUI main thread. sp_session_process_events must also be called periodically based on the next_timeout value returned
The faq covers this https://developer.spotify.com/technologies/libspotify/faq/ and the sp_shell examples serves as an illustration.
回答2:
can you provide a code snippet that shows such error? From a quick test (using the spshell example) I get the logged_in callback called correctly on Android.
回答3:
As daek says, and judging from the output to the tracefile, it seems you're not driving the libspotify event processing using sp_session_process_events() and listening to the notify_main_thread callback.
When correctly implemented you should be able to observe a "sp_session_process_events" line now and then in the tracefile log.
来源:https://stackoverflow.com/questions/11880182/logged-in-callback-never-called-by-libspotify-on-android