用于发射的音频播放器在Android上的网页以流媒体方式流媒体、方式、网页、音频播放器

2023-09-06 15:36:12 作者:人心太凉别太善良

要链接到Shoutcast一样/ HTTP网络收音机流,传统上,你会链接到一个播放列表文件,比如M3U或PLS。从那里,浏览器将启动注册来处理播放列表中的音频播放器。这在任何PC上的伟大工程,棕榈,黑莓和iPhone。

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.

此方法做的没有的,无需安装额外的软件在Android的工作。当然,只是播放列表或 StreamFurious 的可以处理得很好,但我假设必须有一个方法来调用默认情况下,在Android装置通常安装音频或视频播放器

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.

默认情况下,没有音频播放器能够处理M3U或PLS。玩家似乎将其打开,但表示不支持的媒体类型。

By default, no audio player is capable of handling M3U or PLS. The player seems to open it, but says "Unsupported Media Type".

为了使这个比较烦人,浏览器能够流式MP3音频通过HTTP,只需打开一个链接到MP3文件。我曾尝试干脆直接链接到由Shoutcast一样主办的MP3流,它应该结束了在同一个结果,但Shoutcast一样在用户代理字符串检测到Mozilla的,而不是发送数据流,它发送信息页面站。

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.

如何我应该链接到Android上一个Shoutcast一样流,从一个普通的移动网站,而无需使用额外的应用程序?

推荐答案

事实证明,这个是可能的。对于Android,而不是链接到播放列表中像你这样在其他平台上,您只需直接链接到流。 (这似乎正是鲁本Scratton渐渐在他的评论。我想我已经看到了他的意见的前面!)

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.

请注意,你必须做相当多的黑客攻击Shoutcast一样的,如果你想这个工作,因为机器人需要一个有效的HTTP资源,这Shoutcast一样不提供。还要注意的是分块编码似乎并没有在Android 2.2的工作和更早版本。

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.

作为一个侧面说明,如果你不喜欢写自己的code对于这一点,我已经实现串流至Android在AudioPump ,流媒体服务器我的工作。

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.