/ Published in: Java
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package Multimedia; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.metal.MetalLookAndFeel; { { try { } { e.printStackTrace(); } new AudioGUI(); } } package Multimedia; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.io.File; import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JPanel; { public AudioGUI() { this.setTitle("AudioSystem"); this.setSize(240, 100); this.setResizable(false); this.addWindowListener(this); gc.add(new AudioGUIPan()); this.setVisible(true); } { } { } { } { } { } { } { } } { private AudioDevice ad; public AudioGUIPan() { play.addActionListener(this); stop.addActionListener(this); open.addActionListener(this); close.addActionListener(this); this.add(stop); this.add(play); this.add(open); this.add(close); } { if(e.getSource() == close) { } else if(e.getSource() == open) { jfc.setFileFilter(new AudioFilter()); { file = jfc.getSelectedFile().getAbsolutePath(); } } else if(e.getSource() == play) { if(ad != null) ad.play(); } else if(e.getSource() == stop) { if(ad != null) ad.stop(); } } } package Multimedia; import java.io.File; import javax.swing.filechooser.FileFilter; { { return f.getName().toLowerCase().endsWith(".wav") || f.isDirectory(); } { return "Audio File *.wav"; } } package Multimedia; import java.applet.Applet; import java.applet.AudioClip; import java.io.File; import java.net.MalformedURLException; { { try { } { e.printStackTrace(); } } public void play() { ac.play(); } public void stop() { ac.stop(); } public void loop() { } }