How to launch an audio player on Android from a streaming media web page

To reference SHOUTcast / HTTP Internet Radio streams, you have traditionally referenced a playlist file such as M3U or PLS. From there, the browser will launch an audio player registered to process the playlist. This works great on any PC, Palm, Blackberry and iPhone.

This method does not work in Android without installing additional software. Of course, just playlists or StreamFurious can handle it just fine, but I guess there should be a way to call the audio or video player, which is usually the default setting for Android installations.

By default, the audio player is not able to handle M3U or PLS. The player seems to open it, but says "Unsupported media type."

To make this more annoying, the browser is able to stream MP3 audio via HTTP simply by opening the link to the MP3 file. I tried to simply bind directly to the MP3 stream hosted by SHOUTcast, which should end with the same result, but SHOUTcast detects "Mozilla" in the user agent string and instead sends the stream sends an information page to the station.

How can I bind to the SHOUTcast stream on Android from a regular mobile site without using additional applications?

+4
source share
4 answers

The solution for all Android! (tested for 2.1 and later)

It turns out that this is possible . For Android, and not for a link to a playlist, as on other platforms, you simply link directly to the stream. (This seems to be what Ruben Scratton wrote about 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 to the default media player if it can handle it. Then the media player will buffer and start playback.

Note that you need to hack SHOUTcast a bit if you want this to work, since Android requires a valid HTTP resource that SHOUTcast does not provide. Also note that encoded encoding does not work on Android 2.2 and earlier.

As a side note, if you don't want to write your own code for this, I have implemented Android streaming in AudioPump , the streaming server I'm working on.

+1
source

As noted in the comments, what you are asking for is impossible, at least until 3.0 comes out, and even then it will be a long time on most devices. The "no additional applications" limitation is too limited. Here are a few alternatives that violate this limitation, and I urge you instead:

  • Ask users to install the application.
    Yes, this is not what you want, but it is the easiest thing. Just playlists (as you discovered) would be good to recommend.

  • Use flash
    Not everyone has a flash, but for those who can embed a flash widget to play a playlist. I found one that sounds like it will work , only from fast google. Does SHOUTcast have its own flash player?

  • Wait
    In principle, your only option, since this function is simply not in Android.

+3
source

What stream do you use in the M3U file?

You can skip M3U and set the data source directly to the rtsp stream, for example.

 mediaPlayer.setDataSource("rtsp://xxx/stream.stream"); 

Works great

Do not forget to run it in another thread.

+1
source

Finally found a solution! Use the Opera web browser, which prompts you to save the m3u file. Then run justplaylists . Works like a charm on my HTC Incredible 2

-1
source

Source: https://habr.com/ru/post/1339588/


All Articles