Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find out which Music is currently playing [Android]

Is there a way to find out which music is currently playing in the android Music player ? So I want to catch the title time and maybe the author of this music and show it with Textview. Is this possible ?

like image 923
user3339279 Avatar asked Mar 28 '14 19:03

user3339279


1 Answers

In concordance with the Android API here: AudioManager should be what you are looking for

You can create an AudioManager and then call the isMusicActive to retrieve a boolean if it is playing.

You can then use the MediaPlayer API and call the getTrackInfo method which returns an Array of track-related information.

Edit:

Also, MediaPlayer has an isPlaying method which really makes AudioManager rather useless in this scenario.

[Update]

For future viewers of this question; when you create a MediaPlayer object and call the getTrackInfo method; it returns an array TrackInfo[]; the API for TrackInfo[] and it's methods can also be found here.

like image 86
Timothy Frisch Avatar answered Nov 10 '22 01:11

Timothy Frisch