【问题标题】:Pressing "Play" On Spotify through an Intent通过 Intent 在 Spotify 上按“播放”
【发布时间】:2017-08-25 01:38:23
【问题描述】:
我正在尝试通过另一个应用在 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
【解决方案1】:
com.spotify.mobile.android.ui.widget.PLAY
不再起作用了。使用
com.spotify.mobile.android.ui.widget.NEXT
【解决方案2】:
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(); 文档here