如何实现java插入背景音乐
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();
}
}
}
希望可以帮到你,望采纳,谢谢
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();
}
}
}
希望可以帮到你,望采纳,谢谢
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询