Is it possible to get current playing song data on Android? If yes How?

自古美人都是妖i 提交于 2021-02-08 11:33:09

问题


What I want to do is to get current playing song data. Song might be on spotify or any other music player. Actually I want to get data which transferred to phone hardware.

  • Is it possible ?
  • Is there a provided way to do it ?

I've tried, Broadcast Receiver with these filter but onReceived did not invoked. (tested with spotify android app)

    IntentFilter iF = new IntentFilter();
    iF.addCategory("ComponentInfo");
    iF.addCategory("com.spotify.mobile.android.service.SpotifyIntentService");
    iF.addCategory("com.spotify.mobile.android.service.SpotifyService");
    iF.addAction("com.spotify.mobile.android.ui.widget.SpotifyWidget");
    iF.addAction("ComponentInfo");
    iF.addAction("com.spotify");
    iF.addAction("com.spotify.mobile.android.service.SpotifyIntentService");
    iF.addAction("com.spotify.mobile.android.service.SpotifyService");
    iF.addAction("com.spotify.mobile.android.queuechanged");
    iF.addAction("com.spotify.mobile.android.metadatachanged");
    iF.addAction("com.android.music.metachanged");
    iF.addAction("com.android.music.playstatechanged");
    iF.addAction("com.android.music.playbackcomplete");
    iF.addAction("com.android.music.queuechanged");
    registerReceiver(mReceiver, iF);

回答1:


As of API 19, you can use RemoteControlClient.OnMetadataUpdateListener.



来源:https://stackoverflow.com/questions/26025711/is-it-possible-to-get-current-playing-song-data-on-android-if-yes-how

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