0

I cannot figure out how to play an mp3 file. I have a wav file but it is a large file, so I want to make it an mp3.

public static final String RunMusic(String path) {
    
     try {
        AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(path));
        Clip clip = AudioSystem.getClip();
        clip.open(inputStream);
        clip.loop(0);
    } catch (UnsupportedAudioFileException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (LineUnavailableException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return path;
}
khelwood
  • 55,782
  • 14
  • 81
  • 108

0 Answers0