Java 使用 Android 收听广播
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1963105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Listen to a shoutcast with Android
提问by
since quite some time I'm trying to listen to .pls files (shoutcasts). I have to say that I failed horrible. Since StreamFurious can do it it must be possible. First I tried to connect to the shoutcast via sockets (TCP and UDP) --> failed. I couldn't even receive one byte from the server.
因为有一段时间我试图听 .pls 文件(shoutcasts)。我不得不说我失败了。既然 StreamFurious 可以做到,那一定是可能的。首先,我尝试通过套接字(TCP 和 UDP)连接到 Shotcast --> 失败。我什至无法从服务器接收一个字节。
I'm at the verge of tears. I don't even have a clue what's the best way to establish a connection and afterwards continually download/receive the data stream.
我快要热泪盈眶了。我什至不知道建立连接并随后不断下载/接收数据流的最佳方法是什么。
I really hope someone can point me to the right direction and give me a short code snippet if available.
我真的希望有人能指出我正确的方向,并在可用时给我一个简短的代码片段。
Rgds Layne
Rgds 莱恩
采纳答案by CommonsWare
You can try these resources:
您可以尝试以下资源:
http://ostermiller.org/shoutgrab/
http://ostermiller.org/shoutgrab/
http://code.google.com/p/streamscraper/
http://code.google.com/p/streamscraper/
http://code.google.com/p/castor-streamer/
http://code.google.com/p/castor-streamer/
http://mp3imagetagextr.sourceforge.net/ShoutcastPlsDownloader/index.html
http://mp3imagetagextr.sourceforge.net/ShoutcastPlsDownloader/index.html
From what I can tell, you may need to handle the PLS download (via HTTP if I understand correctly) and parsing yourself, but you can then hand the actual audio stream URLs to MediaPlayer for playback. Assuming those streams are within specifications (and not all are), Android should be able to play them back. But I am not a Shoutcast expert by any means.
据我所知,您可能需要处理 PLS 下载(如果我理解正确,通过 HTTP)并自己解析,但您可以将实际的音频流 URL 交给 MediaPlayer 进行播放。假设这些流在规范内(并非所有流都在规范内),Android 应该能够播放它们。但无论如何,我都不是 Shoutcast 专家。
回答by jwadsack
Android 2.2 (FroYo) now natively streams Shoutcast streams.
Android 2.2 (FroYo) 现在可以本地传输 Shoutcast 流。
For older devices, in addition to the above links see http://code.google.com/p/npr-android-app/which includes a proxy for buffering shoutcast streams.
对于较旧的设备,除了上述链接外,请参阅http://code.google.com/p/npr-android-app/,其中包括一个用于缓冲 Shotcast 流的代理。
回答by Marco
Maybe late, but VLC for android was the only really stable app I could find for this. I set up an icecast server on my linux box and could listen to it perfectly using VLC on my old Nexus one. The only (stupid) problem VLC has is that you cant bookmark your URLs in it, you always have to type (or paste) them.
也许晚了,但 VLC for android 是我能找到的唯一真正稳定的应用程序。我在我的 linux 机器上设置了一个 icecast 服务器,并且可以在我的旧 Nexus 机器上使用 VLC 完美地收听它。VLC 唯一的(愚蠢的)问题是你不能在其中为你的 URL 做书签,你总是必须输入(或粘贴)它们。