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

自古美人都是妖i 提交于 2019-11-27 12:14:14
iamgeef

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.

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");

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!