Playing .mp3 and .wav in Java?

前端 未结 14 2131
一整个雨季
一整个雨季 2020-11-22 06:52

How can I play an .mp3 and a .wav file in my Java application? I am using Swing. I tried looking on the internet, for something like this example:<

14条回答
  •  心在旅途
    2020-11-22 07:36

    You need to install JMF first (download using this link)

    File f = new File("D:/Songs/preview.mp3");
    MediaLocator ml = new MediaLocator(f.toURL());
    Player p = Manager.createPlayer(ml);
    p.start();
    

    don't forget to add JMF jar files

提交回复
热议问题