To link to SHOUTcast/HTTP internet radio streams, traditionally you would link to a playlist file, such as an M3U or PLS. From there, the browser would launch the audio player registered to handle the playlist. This works great on any PC, Palm, Blackberry, and iPhone.
This method does not work in Android without installing extra software. Sure, Just Playlists or StreamFurious can handle it just fine, but I am assuming there has to be a way to invoke the audio or video player commonly installed by default on Android installations.
By default, no audio player is capable of handling M3U or PLS. The player seems to open it, but says "Unsupported Media Type".
To make this more annoying, the browser is capable of streaming MP3 audio over HTTP, simply by opening a link to an MP3 file. I have tried simply linking directly to the MP3 stream hosted by SHOUTcast, which should end up in the same result, but SHOUTcast detects "Mozilla" in the user-agent string, and instead of sending the stream, it sends the information page for the station.
How should I link to a SHOUTcast stream on Android, from a normal mobile site, without using extra applications?
A solution for all Android! (tested on 2.1 and later)
It turns out that this is possible. For Android, rather than linking to a playlist like you do on other platforms, you simply link directly to the stream. (This seems to be what Reuben Scratton was getting at in his comment. I wish I had seen his comment earlier!)
The browser will connect to the stream, detect the
Content-Type
, and then decide to pass it off to the default media player if it can handle it. The media player will then buffer and begin playback.Note that you have to do quite a bit of hacking on SHOUTcast if you want this to work, as Android requires a valid HTTP resource, which SHOUTcast does not provide. Also note that chunked encoding doesn't seem to work on Android 2.2 and earlier.
As a side note, if you don't feel like writing your own code for this, I have implemented streaming to Android in AudioPump, a streaming media server I am working on.