Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import jaco.mp3.player.MP3Player;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.io.File;
- import java.awt.event.ActionEvent;
- public class Test {
- private JFrame frame;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- Test window = new Test();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public Test() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame = new JFrame();
- frame.setBounds(100, 100, 450, 300);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().setLayout(null);
- File file = new File("C:\\Users\\Daniel\\Desktop\\Oceans.mp3");
- MP3Player mp3Player = new MP3Player(file);
- JButton btnNewButton = new JButton("play");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- mp3Player.play();
- }
- });
- btnNewButton.setBounds(35, 48, 97, 25);
- frame.getContentPane().add(btnNewButton);
- JButton btnPause = new JButton("pause");
- btnPause.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- mp3Player.pause();
- }
- });
- btnPause.setBounds(197, 79, 97, 25);
- frame.getContentPane().add(btnPause);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement