How is it possible to know what's spotify is playing from an external Android app?

后端 未结 2 955
借酒劲吻你
借酒劲吻你 2020-12-02 19:18

I just found out this settings option in Spotify for Android settings screen:

\"Device broadcast status - allow other apps on your device to see what

相关标签:
2条回答
  • 2020-12-02 19:56

    Spotify broadcasts using the standard com.android.music.metachanged intent-action. Register a BroadcastReceiver for that intent-action, then just pick out metadata using

    String artist = intent.getStringExtra("artist");
    String album = intent.getStringExtra("album");
    String track = intent.getStringExtra("track");

    0 讨论(0)
  • 2020-12-02 20:03

    Spotify has the following intent-actions:

    metadatachanged, playbackstatechanged, and queuechanged.

    queuechanged contains no extra data.
    playbackstatechanged has a boolean value for "playing", and a value for playbackPosition.
    metadatachanged contains artist, album, track, length, and id values.

    You can get Artist, Track, and Album names when the track is changed (manually or automatically) by using com.spotify.mobile.android.metadatachanged

    If Spotify is paused and started again, only playbackstatechanged is broadcast.

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