Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating the Spotify Android library

So I wanted to integrate the spotify library into an android app. I went to https://developer.spotify.com/technologies/libspotify/ and downloaded their lib libspotify-12.1.51-Android-arm-release.tar.gz Problem is that the "Android" samples bundled with the lib aren't actually android projects, they are C code, the lib is a .so file. I have basic knowledge of android ndk and jni but the documentation out there about integrating the library with android is non-existent. Can anyone provide a sample of just playing a track? or point me to where i can find a sample.

like image 796
kev Avatar asked Oct 29 '12 06:10

kev


People also ask

Can I integrate Spotify into my app?

In order to integrate Spotify in your mobile app you need your user to grant you permissions. This guide focuses on how to present this “auth flow” to your user on mobile and create a low friction experience, making the authorization as quick and understandable as possible.

What can you do with the Spotify SDK?

The Spotify iOS SDK allows your iOS application to authenticate users, as well as interact and always stay in sync with the main Spotify application running on the user's device in the background.


2 Answers

Unfortunately, Spotify doesn't have a nice Java library for Android (see this StackOverflow question for more details), so you'll have to manually write a JNI wrapper. As the Android build of libspotify is pretty new, there aren't yet any examples for that either, but I wouldn't be surprised to see the documentation include them soon.

As @juned noted in his comment, this question details how to get the libspotify libraries linked with your Android app. Once you get libspotify linked correctly, you can check out a few Android NDK tutorials for more specific integration help.

If you have troubles during your integration, be sure to check out the example code which Spotify ships with libspotify. The code provides a good reference of how to properly talk with the Spotify service with the library.

like image 120
Nik Reiman Avatar answered Sep 20 '22 15:09

Nik Reiman


Have a look at this sample project doing libspotify on Android: https://github.com/spotify/psyonspotify

As documented in the README:

Looking at the code gives you some insight in:

  • Integration with libspotify
  • Communication through JNI
  • Bridging raw PCM data to OpenSL
like image 40
henka Avatar answered Sep 18 '22 15:09

henka