Who is guilty?
As correctly noted by @Nofate ♦ , by reference stream is in MPEG format. In AudioSystem there is a getAudioFileTypes() method that returns (free translation of the documentation curve ):
Array of file types in which the system can record.
AudioFileFormat.Type[] types = AudioSystem.getAudioFileTypes(); for (AudioFileFormat.Type type : types) { System.out.println(type); }
In my case, the conclusion was:
WAVE AU AIFF
As you can see, there is no support for MPEG. This is the cause of the error.
If the author wrote the error completely
Error: javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream
then one would immediately see a UnsupportedAudioFileException .
What to do?
You can play MPEG from streaming, for example, using the JLayer library as follows:
import java.io.InputStream; import java.net.URL; import javazoom.jl.player.*; public class Main { public static void main(String[] args) throws Exception { String stringURL = "http://89.208.99.16:8088/zvezda_128"; InputStream is = new URL(stringURL).openStream(); Player player = new Player(is); player.play(); } }
Documentation - JLayer javadoc
MPEG, andAudioInputStreamcan onlywav. ___ To play mp3, you can try JavaLayer . - Nofate ♦