Method for launching audio player on Android from web page for streaming media

后端 未结 4 1167
终归单人心
终归单人心 2021-01-13 12:50

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 pla

相关标签:
4条回答
  • 2021-01-13 13:31

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

    0 讨论(0)
  • 2021-01-13 13:37

    What kind of stream does you M3U file contain?

    You can skip the M3U and set your datasource directly to a rtsp stream for example.

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

    Works perfectly

    Don't forget to run it in a different thread.

    0 讨论(0)
  • 2021-01-13 13:50

    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.

    0 讨论(0)
  • 2021-01-13 13:51

    As noted in the comments, what you're asking is impossible, at least until 3.0 comes out and even then it'll be a long time before the functionality is on most devices. The 'without extra apps' constraint is far too limiting. Here are some alternatives that violate this constraint that I urge you to consider instead:

    • Ask users to install an app
      Yes it's not what you want, but it's the easiest thing to do. Just Playlists (as you've discovered) would be a good one to recommend.

    • Use flash
      Not everyone has flash, but for those that do you can embed a flash widget to play the playlist. I found one that sounds like it'll work just from a quick google. Does SHOUTcast have it's own flash player?

    • Wait
      Basically your only other option, since this functionality just isn't there in Android, yet.

    0 讨论(0)
提交回复
热议问题