基于java的音乐播放器的设计(源代码+实验报告)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
主类MUSICPLAYER类:
import java.util.*;
import javax.swing.JSlider;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.EndOfMediaEvent;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.PrefetchCompleteEvent;
import javax.media.Time;
import javax.swing.ButtonGroup;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.filechooser.FileNameExtensionFilter;
public class MusicPlayer implements ActionListener, Serializable,ControllerListener {
private static final long serialVersionUID = 1L;
private JFrame frame = null;
private JPanel controlPanel = null;
private JButton btnPlay = null;
private JButton btnPre = null;
private JButton btnNext = null;
private JScrollPane listPane = null;
private JList list = null;
private DefaultListModel listModel = null;
private JMenuBar menubar = null;
private JMenu menuFile = null, menuAbout = null, menuMode = null;
private JMenuItem itemOpen, itemOpens, itemExit, itemAbout;
private JRadioButtonMenuItem itemSingle, itemSequence ,itemRandom;
private ListItem currentItem = null;
private static Player player = null;
private boolean isPause = false;
private int mode;
private int currentIndex;
private ImageIcon iconPlay = new ImageIcon("d:\\1.jpg");
private ImageIcon iconPre = new ImageIcon("d:\\3.jpg");
private ImageIcon iconNext = new ImageIcon("d:\\2.jpg");
private ImageIcon iconPause = new ImageIcon("d:\\4.jpg");
public static void main(String[] args)
{
new MusicPlayer();
}
public MusicPlayer()
{
init();
}
public void init()
{
frame = new JFrame();
frame.setTitle("音乐播放器");
frame.setSize(400, 300);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
menubar = new JMenuBar();
menuFile = new JMenu("文件");
menuAbout = new JMenu("关于");