當前位置:編程學習大全網 - 網站源碼 - java應用程序中播放mid音樂的代碼,求助!!!!

java應用程序中播放mid音樂的代碼,求助!!!!

import sun.audio.*;

import java.io.*;

import java.awt.*;

import java.awt.event.*;

class Sound5

{

FileInputStream file;

BufferedInputStream buf;

public Sound5()

{

try

{

file=new FileInputStream("1.mid");

buf=new BufferedInputStream(file);

AudioStream audio=new AudioStream(buf);

AudioPlayer.player.start(audio);

}

catch (Exception e) {}

}

}

public class e8165 extends Frame implements ActionListener

{

e8165()

{

super("音頻播放器");

setBounds(300,300,200,100);

setVisible(true);

Button btn=new Button("播放");

setLayout(new FlowLayout());

add(btn);

btn.addActionListener(this);

validate();

// Sound5 play = new Sound5();

addWindowListener(new WindowAdapter()

{ public void windowClosing(WindowEvent e)

{ System.exit(1); }

});

}

public void actionPerformed(ActionEvent e)

{

Sound5 play = new Sound5();

}

public static void main(String[] args)

{

new e8165();

}

}

//下載壹個.mid文件命名為1,放在上述代碼的包下

  • 上一篇:王者如何提升自己的技術?
  • 下一篇:手機微信如何同步到智能手表?
  • copyright 2024編程學習大全網