是否可以在Android上获取当前播放的歌曲数据?如果是,怎么办?

问题描述:

我想要做的是获取当前播放的歌曲数据.歌曲可能在Spotify或任何其他音乐播放器上.其实我想获取传输到手机硬件的数据.

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.

  • 有可能吗?
  • 有提供的方法吗?

我已经尝试过,使用这些过滤器的广播接收器,但是没有调用onReceived.(已通过Spotify安卓应用测试)

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

从API 19开始,您可以使用

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