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,放在上述代碼的包下