【问题标题】: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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-31
      • 2012-05-04
      • 2018-06-10
      • 1970-01-01
      • 2013-08-23
      • 1970-01-01
      • 2018-03-29
      • 2021-02-11
      相关资源
      最近更新 更多