我怎样才能发挥.mp3和.wav在我的Java应用程序文件?我正在使用Swing.我尝试在互联网上寻找类似这样的例子:
public void playSound() {
try {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("D:/MusicPlayer/fml.mp3").getAbsoluteFile());
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start();
} catch(Exception ex) {
System.out.println("Error with playing sound.");
ex.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这只会播放.wav文件.
同样的:
http://www.javaworld.com/javaworld/javatips/jw-javatip24.html
我希望能够使用相同的方法播放.mp3文件和.wav文件.
我已经安装了JavaFX 2.0 SDK,现在我想用Eclipse做一个JavaFX应用程序.但是我如何javafx.*在Eclipse中使用这些类?
在官方的JavaFX Eclipse插件似乎是为JavaFX 1.2和过时.
当我尝试安装e(fx)clipse插件时,我收到此错误:
Cannot complete the install because one or more required items could not be found.
Software being installed: efxclipse 0.0.8.201111131640 (at.bestsolution.efxclipse.feature.feature.group 0.0.8.201111131640)
Missing requirement: Eclipse DI integration for JavaFX 0.0.8.201111131640 (at.bestsolution.efxclipse.runtime.di 0.0.8.201111131640) requires 'bundle org.eclipse.e4.core.contexts 0.9.0' but it could not be found
Cannot satisfy dependency:
From: efxclipse 0.0.8.201111131640 (at.bestsolution.efxclipse.feature.feature.group 0.0.8.201111131640)
To: at.bestsolution.efxclipse.runtime.feature.feature.group [0.0.8.201111131640]
Cannot satisfy dependency:
From: FX Runtime 0.0.8.201111131640 (at.bestsolution.efxclipse.runtime.feature.feature.group 0.0.8.201111131640)
To: at.bestsolution.efxclipse.runtime.di [0.0.8.201111131640]
Run Code Online (Sandbox Code Playgroud)