通过意图在Spotify上按“播放”

问题描述 投票:3回答:2

我正试图通过另一个应用程序恢复在spotify上播放暂停的歌曲。

我目前的代码:

Log.v(TAG, "Resuming Spotify");
Intent playSpotify = new Intent("com.spotify.mobile.android.ui.widget.PLAY");
playSpotify.setPackage("com.spotify.music");
context.sendBroadcast(playSpotify);

这不起作用。然而,它会暂停正在播放的歌曲。

任何建议/资源表示赞赏!

android android-intent spotify
2个回答
0
投票
com.spotify.mobile.android.ui.widget.PLAY

不再起作用了。使用

com.spotify.mobile.android.ui.widget.NEXT

0
投票
Intent playSpotify = new Intent("com.spotify.mobile.android.ui.widget.NEXT");
playSpotify.setPackage("com.spotify.music");
sendBroadcast(playSpotify);

playSpotify = new Intent("com.spotify.mobile.android.ui.widget.PREVIOUS");
playSpotify.setPackage("com.spotify.music");
sendBroadcast(playSpotify);

这可能是一种解决方法。

更新:使用SpotifyAppRemote.getPlayerApi().resume(); Docs here

© www.soinside.com 2019 - 2024. All rights reserved.