1

I know this has been addressed before here but this solution doesn't work for me, and I don't know why.

I follow the given steps, but at 5 there is no dialog that comes up. I am trying to add mp3plugin.jar to my dependencies, but after following this process, I still get an UnsupportedAudioFileException at runtime.

What am I doing wrong?

Here is a screencast of what I am doing: http://www.screenr.com/G70H

Here is the code that uses the audio file:

import javax.sound.sampled.*;
import java.io.File;
import java.io.IOException;

public class Sound {
private Clip clip;

public Sound (String in){
    try{
        File file = new File ("src/music/" + in + ".mp3");
        //System.out.println(file.getAbsolutePath());
        clip = AudioSystem.getClip();
        AudioInputStream inputStream = AudioSystem.getAudioInputStream(file);
        clip.open(inputStream);
    } catch (IOException e){
        e.printStackTrace();
    } catch (LineUnavailableException e){
        e.printStackTrace();
    } catch (UnsupportedAudioFileException e){
        e.printStackTrace();
    }
}
public void stop(){
    clip.stop();
}
public void loop(){
    if (!clip.isActive()){
        clip.setFramePosition(0);
        clip.loop(Clip.LOOP_CONTINUOUSLY);
    } else {
        System.out.println("already playing..");
    }
}
}

And in this runs it:

Sound sound = new Sound (in.readLine()); //from a bufferedreader
sound.loop();

I know this works because it works with .wav files.

Community
  • 1
  • 1
sideways8
  • 153
  • 1
  • 1
  • 14
  • That is not a classpath exception. Something else is going wrong. We'll need to know what library you're using and (ideally) a code sample to reproduce the error to be able to help you. – Daniel Kaplan Aug 27 '13 at 21:01
  • Ok, I'll edit in the Sound class I've created and the code that uses it. I am just using JMF. – sideways8 Aug 27 '13 at 21:16

0 Answers0