如何使用纯 Java 流式传输 mp3
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/657921/
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
How to stream mp3 using pure Java
提问by npellow
Is it possible to stream mp3s using pure Java? If so, what are the best resources to implement this.
是否可以使用纯 Java 流式传输 mp3?如果是这样,实现这一目标的最佳资源是什么。
If not, are any other music formats streamable using Java only?
如果没有,是否有任何其他音乐格式只能使用 Java 进行流式传输?
回答by VonC
As Mario says, JMF- Java Media Frameworkis a good starting point.
正如马里奥所说,JMF- Java 媒体框架是一个很好的起点。
What Mario does not say is that Sun killed MP3 support since 2.1.1b as detailed in the "My Lost Streaming MP3 Article" blog entry.
马里奥没有说的是,Sun 取消了自 2.1.1b 以来对 MP3 的支持,详见“我丢失的 MP3 流媒体文章”博客条目。
So you need to add a pluginto support MP3:
the JMF Formats listdoes mention MP3 (under the ACM -- Window's Audio Compression Manager support -- section), but only for Windows, and not with JMF alone.
所以,你需要添加一个插件来支持MP3:
在JMF格式列表中未提到MP3(ACM的下-窗口的音频压缩管理支持-部分),但只适用于Windows,而不是与单独JMF。
回答by Sandman
You could use MP3SPIfrom JavaZoom to stream MP3 files
您可以使用JavaZoom 中的 MP3SPI 来流式传输 MP3 文件
As it says on their webpage: "MP3SPI is a Java Service Provider Interface that adds MP3 (MPEG 1/2/2.5 Layer 1/2/3) audio format support for Java Platform. It supports streaming, ID3v2 frames, Equalizer, .... "
正如他们在他们的网页上所说:“MP3SPI 是一个 Java 服务提供者接口,它为 Java 平台添加了 MP3(MPEG 1/2/2.5 第 1/2/3 层)音频格式支持。它支持流媒体、ID3v2 帧、均衡器、.. ..”
People have already used it to build applicatons that stream from Shoutcast
人们已经使用它来构建来自 Shoutcast 的应用程序
Hope this helps
希望这可以帮助
回答by Mario Ortegón
I think you can use the Java Media Frameworkfrom SUN to achieve what you want. Being this the official SUN implementation this would be the way to go. I am pretty sure that the actual streaming is native though.
我认为您可以使用SUN的Java Media Framework来实现您想要的。作为 SUN 的官方实施,这将是要走的路。我很确定实际的流媒体是原生的。
I looked in the FAQ and I found the following answer:
我查看了常见问题解答,我找到了以下答案:
Q: Will JMF 2.1.1 support streaming?
Yes. JMF 2.1.1 provides RTP/RTSP streaming support.
JMF 2.1.1 also provides HTTP and FTP streaming support on the client side.
问:JMF 2.1.1 是否支持流式传输?
是的。JMF 2.1.1 提供 RTP/RTSP 流支持。
JMF 2.1.1 还在客户端提供 HTTP 和 FTP 流支持。

