如何实现java插入背景音乐

2024-12-04 15:29:26
推荐回答(1个)
回答1:

你是要播放哪类型的音乐呢,可以到网上找个mp3音乐的jar包就可以了,相关程序如下 :public class Music extends Thread{

public void run()
{
Sequencer sequencer;
try{
sequencer = MidiSystem.getSequencer();
sequencer.open();
File my = new File("88.mid");
Sequence mySeq = MidiSystem.getSequence(my);
sequencer.setSequence(mySeq);
sequencer.setLoopCount(Sequencer.LOOP_CONTINUOUSLY);
sequencer.start();

}catch(Exception e){
e.printStackTrace();
}
}
}
希望可以帮到你,望采纳,谢谢