我正在尝试制作一个可以在音乐播放器播放歌曲时显示歌曲内部歌词的 android 应用程序。我不想使用 .lrc 文件。有没有人可以选择显示歌曲的内部歌词?
下面的代码:当音乐播放器播放歌曲时读取动作。我把它放在 onCreate() 中。
IntentFilter filter = new IntentFilter();
// Read action when music player changed current song
// I just try it with stock music player form android
//Google Android player
filter.addAction("com.android.music.playstatechanged");
filter.addAction("com.android.music.playbackcomplete");
filter.addAction("com.android.music.metachanged");
//HTC Music
filter.addAction("com.htc.music.playstatechanged");
filter.addAction("com.htc.music.playbackcomplete");
filter.addAction("com.htc.music.metachanged");
//MIUI Player
filter.addAction("com.miui.player.playstatechanged");
filter.addAction("com.miui.player.playbackcomplete");
filter.addAction("com.miui.player.metachanged");
//Real
filter.addAction("com.real.IMP.playstatechanged");
filter.addAction("com.real.IMP.playbackcomplete");
filter.addAction("com.real.IMP.metachanged");
//SEMC Music Player
filter.addAction("com.sonyericsson.music.playbackcontrol.ACTION_TRACK_STARTED");
filter.addAction("com.sonyericsson.music.playbackcontrol.ACTION_PAUSED");
filter.addAction("com.sonyericsson.music.TRACK_COMPLETED");
filter.addAction("com.sonyericsson.music.metachanged");
//rdio
filter.addAction("com.rdio.android.metachanged");
filter.addAction("com.rdio.android.playstatechanged");
//Samsung Music Player
filter.addAction("com.samsung.sec.android.MusicPlayer.playstatechanged");
filter.addAction("com.samsung.sec.android.MusicPlayer.playbackcomplete");
filter.addAction("com.samsung.sec.android.MusicPlayer.metachanged");
filter.addAction("com.sec.android.app.music.playstatechanged");
filter.addAction("com.sec.android.app.music.playbackcomplete");
filter.addAction("com.sec.android.app.music.metachanged");
//Winamp
filter.addAction("com.nullsoft.winamp.playstatechanged");
filter.addAction("com.nullsoft.winamp.metachanged");
//Amazon
filter.addAction("com.amazon.mp3.playstatechanged");
filter.addAction("com.amazon.mp3.metachanged");
//Rhapsody
filter.addAction("com.rhapsody.playstatechanged");
filter.addAction("com.rhapsody.metachanged");
//PowerAmp
filter.addAction("com.maxmpz.audioplayer.playstatechanged");
filter.addAction("com.maxmpz.audioplayer.metachanged");
// MyTouch4G
filter.addAction("com.real.IMP.metachanged");
//appollo
filter.addAction("com.andrew.apollo.metachanged");
//will be added any....
//scrobblers detect for players (poweramp for example)
//Last.fm
filter.addAction("fm.last.android.metachanged");
filter.addAction("fm.last.android.playbackpaused");
filter.addAction("fm.last.android.playbackcomplete");
//A simple last.fm scrobbler
filter.addAction("com.adam.aslfms.notify.playstatechanged");
//Scrobble Droid
filter.addAction("net.jjc1138.android.scrobbler.action.MUSIC_STATUS");
registerReceiver(mReceiver, filter);
//scrobbling finished
这里是获取音乐信息(mReceiver)功能
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
String cmd = intent.getStringExtra("command");
Log.d("mIntentReceiver.onReceive ", action + " / " + cmd);
String lyric = intent.getStringExtra("lyric");
String artist1 = intent.getStringExtra(MediaStore.Audio.AudioColumns.ARTIST);
String album1 = intent.getStringExtra(MediaStore.Audio.AlbumColumns.ALBUM);
String track1 = intent.getStringExtra(MediaStore.Audio.AudioColumns.TITLE_KEY);
Toast.makeText(context, "Command : "+cmd+"\n Artist : "+artist1+"\n Album :"+album1+"\n Track : "+track1+"\n Lyric : "+lyric , Toast.LENGTH_SHORT).show();
}
};
但是这段代码中的歌词显示为空。有没有人有任何解决方案?