好的,我試圖在應用程序打開時讓聲音文件永遠循環播放。這是目前我運行聲音文件的一段代碼。無法循環播放MP3文件
public class Game {
public static void main(String[] args) {
JFrame window = new JFrame("Josh's 2D College Project");
window.setContentPane(new GamePanel());
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
window.pack();
window.setVisible(true);
try{
File file = new File("C:/Users/Josh Scott (Zinotia)/Desktop/2D College Project/Resources/Sounds/BGSong.mp3");
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
try{
Player player = new Player(bis);
player.play();
} catch(JavaLayerException ex) {}
} catch(IOException e){}
}
}
我正在使用JavaZoom的JavaLayer來播放Mp3文件。任何人都可能給我另一種方式來循環&使用聲音文件以不同的方式或使用JavaLayer。
你好,請你看看(http://stackoverflow.com/a/17032994/824495) –