JAVA 播放器Applet

  • m5_537203
    了解作者
  • 56.4KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-28 02:31
    上传日期
JAVA 播放器Applet JAVA 播放器Applet 第二次作业 课程设计
bofangqi.rar
  • bofangqi
  • images
  • next.png
    4.3KB
  • stop.png
    4.8KB
  • front.png
    4.3KB
  • play.png
    5.9KB
  • Thumbs.db
    14.5KB
  • pause.png
    5.6KB
  • .settings
  • org.eclipse.jdt.core.prefs
    598B
  • MusicPlayer
  • myPackage
  • SongListData.java
    1.2KB
  • AudioFilter.java
    374B
  • MainPanel.java
    892B
  • PlayPanel.java
    3.3KB
  • PlayListData.java
    1.2KB
  • MainApplication.java
    217B
  • ListPanel.java
    18.2KB
  • MusicPlayerApplet.java
    341B
  • MainFrame.java
    727B
  • bin
  • myPackage
  • PlayPanel$Btlistener.class
    1.4KB
  • PlayPanel.class
    1.5KB
  • SongListData.class
    1.5KB
  • jfei
  • myPackage
  • SongListData.java
    1.2KB
  • AudioFilter.java
    374B
  • MainPanel.java
    892B
  • PlayPanel.java
    3.3KB
  • PlayListData.java
    1.2KB
  • MainApplication.java
    217B
  • ListPanel.java
    18.2KB
  • MusicPlayerApplet.java
    341B
  • MainFrame.java
    727B
  • .project
    384B
  • .classpath
    259B
内容介绍
/** * 显示列表面板 */ package myPackage; import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import javax.media.*; import javax.swing.*; /** * @author guanchun * */ public class ListPanel extends JPanel implements ControllerListener{ public ListPanel(MainPanel pane) { panel = pane; setLayout(new BorderLayout(2,2)); northpanel = new JPanel(); menupanel = new JPanel(); leftpanel = new JPanel(); rightpanel = new JPanel(); companel = new JPanel(); add(northpanel,BorderLayout.NORTH); add(leftpanel,BorderLayout.WEST); add(rightpanel,BorderLayout.CENTER); northpanel.setPreferredSize(new Dimension(300,50)); leftpanel.setPreferredSize(new Dimension(100,300)); menubar = new JMenuBar(); filemenu = new JMenu("文件"); listmenu = new JMenu("列表"); modemenu = new JMenu("模式"); menubar.add(filemenu); menubar.add(listmenu); menubar.add(modemenu); addfileItem = new JMenuItem("添加文件"); addFileItem = new JMenuItem("添加文件夹"); delfileItem = new JMenuItem("删除文件"); filemenu.add(addfileItem); filemenu.add(addFileItem); filemenu.add(delfileItem); addlistItem = new JMenuItem("新建列表"); dellistItem = new JMenuItem("删除列表"); listmenu.add(addlistItem); listmenu.add(dellistItem); oneloopItem = new JMenuItem("单曲循环"); orderlyItem = new JMenuItem("顺序播放"); loopItem = new JMenuItem("循环播放"); modemenu.add(oneloopItem); modemenu.add(orderlyItem); modemenu.add(loopItem); northpanel.setLayout(new BorderLayout()); northpanel.add(menupanel,BorderLayout.SOUTH); menupanel.setPreferredSize(new Dimension(300,25)); menupanel.setLayout(new BorderLayout()); menupanel.add(menubar,BorderLayout.WEST); modelabel = new JLabel("顺序播放"); menupanel.add(modelabel,BorderLayout.EAST); modelabel.setPreferredSize(new Dimension(60,25)); modelabel.setFont(new Font("宋体",Font.PLAIN,12)); northpanel.add(companel,BorderLayout.NORTH); companel.setPreferredSize(new Dimension(300,25)); companel.setLayout(new BorderLayout()); companel.setBackground(Color.lightGray); playlistdata = new PlayListData(); leftlist = new JList(); leftpanel.setLayout(new BorderLayout()); leftpanel.add(new JScrollPane(leftlist),BorderLayout.CENTER); leftlist.setFont(new Font("宋体",Font.PLAIN,12)); rightlist = new JList(); rightpanel.setLayout(new BorderLayout()); rightpanel.add(new JScrollPane(rightlist),BorderLayout.CENTER); rightlist.setFont(new Font("宋体",Font.PLAIN,12)); setActionListener (); } //获得播放路径 public String getPlaypath() { playindex = leftlist.getSelectedIndex(); if(playindex!=-1) { if(nextORfront == null) { songindex = rightlist.getSelectedIndex(); if(songindex!=-1) { songlistdata = playlistdata.getSongindex(playindex); playpath = songlistdata.getsongpath(songindex); } } //下一曲 else if(nextORfront.equals("next")) { songindex = rightlist.getSelectedIndex(); if(songindex != -1) { songlistdata = playlistdata.getSongindex(playindex); if(songindex == songlistdata.getlength()-1)//列表中的最后一曲 { if(playmode == 3) //循环播放 { songindex = 0; rightlist.setSelectedIndex(songindex);//跳到第一曲 } playpath = songlistdata.getsongpath(songindex); } else { if(playmode == 1) {} else songindex++; rightlist.setSelectedIndex(songindex); playpath = songlistdata.getsongpath(songindex); } } } //上一曲 else if(nextORfront.equals("front")) { songindex = rightlist.getSelectedIndex(); if(songindex != -1) { songlistdata = playlistdata.getSongindex(playindex); if(songindex == 0)//列表中的第一曲 { if(playmode == 3) //循环播放 { songindex = songlistdata.getlength()-1; rightlist.setSelectedIndex(songindex);//跳到最后一曲 } playpath = songlistdata.getsongpath(songindex); } else { if(playmode == 1) {} else songindex--; rightlist.setSelectedIndex(songindex); playpath = songlistdata.getsongpath(songindex); } } } } else playpath = null; return playpath; } //播放 public void startplay() { if(aplayer != null) { aplayer.start(); } else { if(getPlaypath() != null) { nextORfront = null; createplayer(getPlaypath()); } else { } } } //暂停 public void puaseplay() { if(aplayer != null) { //state = 0; aplayer.stop(); } else {} } //停止播放 public void stopplay() { if(aplayer != null) { aplayer.close(); aplayer = null; } } //下一曲 public void nextplay() { if(aplayer != null) { nextORfront = "next"; aplayer.close(); aplayer = null; startplay(); } } //上一曲 public void frontplay() { if(aplayer != null) { nextORfront = "front"; aplayer.close(); aplayer = null; startplay(); } } //保存列表数据 public void saveList() { File file = new File("save/"); File[] files= file.listFiles(); for(int i = 0; i < files.length; i++) { files[i].delete(); } if(playlistdata.getLength() == 0) return; //创建save文件夹 try { new File("save/").mkdir(); } catch(SecurityException e) { JOptionPane.showMessageDialog(ListPanel.this, "创建文件夹失败!", "错误", JOptionPane.ERROR_MESSAGE); return; } Properties playlist = new Properties(); if( playlistdata.getLength() == 0) return; //保存列表数目 playlist.put("playlistnum",String.valueOf(playlistdata.getLength())); //保存上次退出时播放列表计数器 playlist.put("playindex",String.valueOf(playindex)); //保存上次退出时歌曲列表计数器 playlist.put("songindex",String.valueOf(songindex)); int i = 0; //保存列表名 while( i < playlistdata.getLength()) { playlist.put("listname"+i,playlistdata.getListname(i)); i++; } try{ FileOutputStream out = new FileOutputStream("save/playlist.properties"); playlist.store(out, "save.properties"); out.close(); }catch(IOException ex){ JOptionPane.showMessageDialog(ListPanel.this, "文件输出错误!", "错误", JOptionPane.ERROR_MESSAGE); return; } //保存歌曲列表 for(i = 0; i < playlistdata.getLength(); i++) { Properties songlist = new Properties(); //保存第i个播放列表的歌曲数 int songnum = playlistdata.getSongindex(i).getlength(); songlist.put("songnum", String.valueOf(songnum)); for(int j = 0; j < songnum; j++) { songlist.put("songname"+j,playlistdata.getSongindex(i).getsongname(j)); songlist.put("songpath"+j,playlistdata.getSongindex(i).getsongpath(j)); } try{ FileOutputStream out = new FileOutputStream("save/songlist"+i+".properties"); songlist.store(out, "save/songlist"+i+".properties"); out.close(); }catch(IOException ex){ JOptionPane.showMessageDialog(ListPanel.this, "文件输出错误!", "错误", JOptionPane.ERROR_MESSAGE); return; } } } //程序开始运行时获得以前保存的列表数据 public void getData() { //读入播放列表数据 Properties setplaylist = new Properties(); try { FileInputStream in = new FileInputStream("save/playlist.properties"); setplaylist.load(in); in.close(); }catch(IOException ex){ //JOptionPane.showMessageDialog(ListPanel.this, "文件读入错误!", "错误", JOptionPane.ERROR_MESSAGE); return; } int lists = Integer.parseInt(setplaylist.getProperty("playlistnum"));
评论
    相关推荐
    • Java
      Java 对于Java练习
    • java
      Java Java基础
    • Java
      Java 我创建的Java项目
    • JAVA教程
      一本非常不错的清华大学java教程,讲解非常详细,看了就知道。
    • Java Cipher
      Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码
    • javabank
      Java银行 Java com的模拟操作将在bancárias上发布! 要求:Java 8。
    • java 李兴华
      java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java ...
    • JAVA教程
      详细介绍了JAVA语言程序设计,对JAVA的基础知识运用实例的方式来讲解,使初学者能够非常轻松的掌握。
    • java程序
      java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点
    • Java
      Java 2021/02/19 .java Main.java 学生.java Bmi.java 。班级 Bmi类 主类 MyBmi.class 学生班 学生样本类 2021/02/20 .java DeleteFile.java WriteFile.java MyDataPrint.java 。班级 DeleteFile.class ...