问题
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 ?
回答1:
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.
来源:https://stackoverflow.com/questions/22721667/find-out-which-music-is-currently-playing-android