javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file when loading wav file

..any ideas how to fix this exception, ..

Since WAV is a container format, it might include any number of encoding internally.

..wav files can be encoded with a variety of codecs to reduce the file size (for example the GSM or MP3 codecs).

See the Java Sound info. page for details no how to add support for an extra encoding (using the SPI), and a lead on an MP3 SPI.

..or if there’s another way to get file duration ?

Not really. With compressed formats, bit rate is variable and there is no way to know for sure how long a track takes short of converting it to PCM or similar formats, in which the bit rate is constant & the track time is completely resolved.

Leave a Comment