Click here to Skip to main content
12,954,856 members (65,200 online)
Rate this:
Please Sign up or sign in to vote.
See more:
how to read .wma song file in java. I'm using this code. but this code is error.

(Error == javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file )


private void playAudio() {
        try {
            File soundFile =
                    new File("Track_1.wma");
            audioInputStream = AudioSystem.getAudioInputStream(soundFile);
            audioFormat = audioInputStream.getFormat();
            DataLine.Info dataLineInfo =
                    new DataLine.Info(
            sourceDataLine =
                    (SourceDataLine) AudioSystem.getLine(
            new PlayThread().start();
        } catch (Exception e) {
class PlayThread extends Thread {
        byte tempBuffer[] = new byte[10000];
        public void run() {
            try {
                int cnt;
                while ((cnt =
                        tempBuffer, 0, tempBuffer.length)) != -1
                        && stopPlayback == false) {
                    if (cnt > 0) {
                                tempBuffer, 0, cnt);
            } catch (Exception e) {

Please help me.
Posted 3-Oct-12 19:01pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That exception will stay. *.wma files are not supported by standard.

The sound support is currently bad in Java. The Sound API is not developed actively, there is no developer left after oracle toke over the Java development.

Simplest solution would be to use *.wav files.

Check this for some information on the Sound API:
Java Sound Programmer Guide[^] @

There is a lib available for mp3 support under JMF:
Java MP3 PlugIn[^]

And the FOBS project is said to be supporting WMA-Files. But that Project is also not continuing:[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,539
CHill60 3,490
Maciej Los 3,153
ppolymorphe 2,030
Jochen Arndt 1,975

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100