如何使用 Android Spotify SDK 在应用程序中直接播放音乐?

How can I play music directly in an app using the Android Spotify SDK?

我目前正在使用 Android Spotify SDK,我想直接在应用程序中播放音乐。现在我只能通过 Spotify Player 播放音乐:

if (mSpotifyAppRemote != null && spotifyUri != null) {
                    spotifyAppRemote.playerApi.play(spotifyUri)
                            .setResultCallback {
                              /...
                            }

但是我想在应用程序中播放音乐。到目前为止我还没有找到解决办法。但是必须有一个,因为其他应用已经实现了这个功能。

通过新的 Spotify SDK,他们正在推动开发人员通过 Spotify 应用程序而不是在他们自己的应用程序中播放音乐。他们以前的 SDK(which they shut down on November 1st, 2019) allowed developers to do that but they have now migrated away from supporting that way. Some repos/packages still exist in trying to support the previous implementation like the react-native-spotify integration but they are facing a similar issue since the SDK has been removed. 仍然通过自己的应用程序播放音乐的应用程序现在使用已弃用的 SDK,尽管它可能仍然有效,但不受支持,如果他们想要升级他们的应用程序,则需要更新. 至少Spotify是这样,可能还有其他允许不同控制的音乐流媒体服务。