Reputation: 11002
I can successfully listen to an audio stream with the MediaPlayer interface, but how can I get properties of the stream like the current bit rate, or the stream text (lots of streams like on line radios include the currently playing track)?
I tried to find this information but couldn't, if these things are possibly is there a list somewhere on the android dev site where the various available 'properties' are listed?
Upvotes: 6
Views: 7810
Reputation: 4907
If your stream is a shoutcast/icecast stream then you can use the utility class at http://code.google.com/p/streamscraper/ to extract the metadata including the song title. Alternatively, you can build your own metadata extractor. Take a look at http://www.smackfu.com/stuff/programming/shoutcast.html for more info.
Upvotes: -2
Reputation: 31493
I could be making this harder than it needs to be, but you can decode a frame of the Stream with Jlayer or some other MP3 decoding library to get the info you are looking for. Not sure if there is a way to do this with just the Android sdk.
Upvotes: 0
Reputation: 1279
First, the Android DEV site is the site with all class information - but sometimes hard to find what you need. In that case, checking the java source of the class can be quite helpful.
From a quick look into the SDK, there is an onInfoListener
interface, which you can implement in a class extending MediaPlayer
. That needs you to have public boolean onInfo(MediaPlayer mp, int what, int extra)
implemented.
http://developer.android.com/reference/android/media/MediaPlayer.OnInfoListener.html states there is a what=MEDIA_INFO_METADATA_UPDATE
.
But - checking google for that would give the idea that this never gets called :-/ So eventually you are on your own with that...
Upvotes: 3