I've been looking around the entire web, and tried a bunch of different stuff, but I can't figure out how to play streaming audio in java - which is crucial for the application Iam developing now. It's a radio. I've already written it for the web, but I want a desktop version, and I though java might be the way to go.
Streams look like this (mostly MP3s): http://lyd.nrk.no/nrk_radio_mp3_mp3_h (example from NRK MP3 - a radio channel in Norway).
So where should I go from here? I've tried both JMF, FMJ and a lot of other stuff. I just want to stream audio.. I appreciate all answers, please help me out!
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.
来源:https://stackoverflow.com/questions/10438351/streaming-audio-radio-in-java