I'm trying to create a simple player in android following guidance from http://damienradtke.org/playing-with-the-spotify-api/ , using it i'm able to play a track from spotify in ubuntu but i cant even build on android. So far i'm able to query for a track from spotify but its been a nightmare when i've tried to add playback capabilities using ALSA. I've tried using openAl and am still stuck. Is there a much simpler way to play streamed audio in jni?
at the end of my &on_search_complete callback i call a function 'play' which looks like this:
void play(sp_session *session, sp_track *track)
{
if(DEBUG_MODE) __android_log_print(ANDROID_LOG_INFO, "spotify", "attempting to play track...");
sp_error error = sp_session_player_load(session, track);
if (error != SP_ERROR_OK) {
if(DEBUG_MODE) __android_log_print(ANDROID_LOG_INFO, "spotify", "Error: %s\n", sp_error_message(error));
exit(1);
}
if(DEBUG_MODE) __android_log_print(ANDROID_LOG_INFO, "spotify", "Playing...");
sp_session_player_play(session, 1);
}
this leads to the &on_music_delivery callback being executed, i believe this is where i need to add my playback code.
static int on_music_delivery(sp_session *session, const sp_audioformat *format, const void *frames, int num_frames)
{
if(DEBUG_MODE) __android_log_print(ANDROID_LOG_INFO, "spotify", "in on_music_delivery");
}
I've had little success building my code with ALSA, can someone point me to the right direction here. Its frustrating and i dont want to give up at the last hurdle. NB: i'm a beginner in the C language