Streaming audio/radio in Java?

大城市里の小女人 提交于 2019-12-05 22:14:15

Have you tried Java FX 2 (latest version is 2.1)? It has a media component that's rather easy to use. Works well for video including streaming video (even h.264 in JavaFX 2.1) in my experience. Can play normal mp3 files with it, never tried streaming mp3 though.

JavaFX 2 does not support mp3 streams, but you can hack it.

Open a socket connection to any ICY mp3 stream in a new thread and start saving the bytes to a file.

After a few kilobytes received open the file in the JavaFX MediaPlayer and play it, but do not stop receiving bytes on the another thread.

This is what worked for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!