Integrating the Spotify Android library

后端 未结 4 1935
暗喜
暗喜 2021-01-19 01:36

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.5

相关标签:
4条回答
  • 2021-01-19 02:09

    Spotify have announced that they released the Android SDK(https://developer.spotify.com/technologies/spotify-android-sdk/).
    And the tutorial is here(https://developer.spotify.com/technologies/spotify-android-sdk/tutorial/), so you can easily integrate Spotify into your Android application.

    0 讨论(0)
  • 2021-01-19 02:14

    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.

    0 讨论(0)
  • 2021-01-19 02:27

    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
    0 讨论(0)
  • 2021-01-19 02:29

    Spotify have published a SDK BETA version for android.

    https://github.com/spotify/android-sdk

    They have a few examples of initializing a player and playing a track using TRACK_CHANGE event (Only available from Beta10). Here is one that doesn't use TRACK_CHANGE:

               mPlayer = Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() {
                @Override
                public void onInitialized(Player player) {
                    mPlayer.addConnectionStateCallback(MainActivity.this);
                    mPlayer.addPlayerNotificationCallback(MainActivity.this);
                    mPlayer.play("spotify:track:2TpxZ7JUBn3uw46aR7qd6V");
                }
    
                @Override
                public void onError(Throwable throwable) {
                    Log.e("MainActivity", "Could not initialize player: " + throwable.getMessage());
                }
            });
    

    (Took the code from the tutorial - https://developer.spotify.com/technologies/spotify-android-sdk/tutorial/)

    0 讨论(0)
提交回复
热议问题