Reputation: 11
I am trying to make a android app that can display the song internal lyric as a music player is playing a song. I don't want to use the .lrc file. Is anyone has other option to show the song internal lyric?
Below code: Read action when music player is playing a song. I put it in 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
Here is to get the music info (mReceiver) function
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();
}
};
But the lyric is showing null from this code. Is anyone has any solution?
Upvotes: 1
Views: 3865
Reputation: 894
This might not answer the question completely but i hope it helps to refine your problem a bit. lyric is a kind of metadata like thumbnail, the song should have the lyric metadata added if you want to display it. Make sure it is there.
Upvotes: 1