java 引用程序 播放music
总结:话不多说代码如下:
public class MusicDemo { public static void main(String[] args) throws Exception { // 创建音乐文件输入流对象 InputStream in = new FileInputStream("musics/flourish.mid"); // 创建音频流对象 final AudioStream audioStream = new AudioStream(in); new Thread(new Runnable() { @Override public void run() { // 使用音频播放器播放声音 AudioPlayer.player.start(audioStream); } }).start(); Thread.sleep(3000); // 停止声音播放 AudioPlayer.player.stop(audioStream); } }
elk