怎么在java Jframe中加背景音乐 求java源代码 谢谢
展开全部
注意要try catch一下,我这里就不做了。
===============================
要导入的包(都是java自带的)
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
import sun.audio.ContinuousAudioDataStream;
下面是要添加的代码(两行)(它会自动循环播放)
ContinuousAudioDataStream sound = new ContinuousAudioDataStream(new AudioStream(new FileInputStream("F:\\sound\\song.wav")).getData());
AudioPlayer.player.start(sound);
===============================
要导入的包(都是java自带的)
import sun.audio.AudioPlayer;
import sun.audio.AudioStream;
import sun.audio.ContinuousAudioDataStream;
下面是要添加的代码(两行)(它会自动循环播放)
ContinuousAudioDataStream sound = new ContinuousAudioDataStream(new AudioStream(new FileInputStream("F:\\sound\\song.wav")).getData());
AudioPlayer.player.start(sound);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询