user1226162
user1226162

Reputation: 2042

could not get audio input stream from input URL

I am trying to run a sound file in Java using this code:

  public class Audio3
  {
     public static void main(String[] args) throws Exception
      { 
        URL soundFile =new URL( 
          "http://everyayah.com/data/Ghamadi_40kbps/audhubillah.mp3");
        AudioInputStream ais = AudioSystem.getAudioInputStream(soundFile);
        AudioPlayer.player.start(ais);
      }
  }

I am getting this exception

javax.sound.sampled.UnsupportedAudioFileException: 
    could not get audio input stream from input URL

Any idea what could be the reason?

Upvotes: 1

Views: 6069

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168845

According to the JavaSound info. page.

MP3 decoding support

The Java Sound API does not support many formats of sampled sound internally. In a 1.6.0_24 Oracle JRE getAudioFileTypes() will generally return {WAVE, AU, AIFF}. An MP3 decoder at least, is close by. The mp3plugin.jar of the Java Media Framework supports decoding MP3s.

I can vouch for that information since I've successfully loaded MP3s using Java Sound and the MP3 SPI (& also wrote the info. page ;) ). The JMF installer download is becoming hard to find, but you can get the mp3plugin.jar direct from where I put it for use in JWS apps.

Upvotes: 3

Related Questions