jmf MP3播放器

  • N0_786732
    了解作者
  • 5MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-09 10:38
    上传日期
基于jfm和swing的mp3播放器,包含jmf安装包和开发源码,mp3主要功能有:截取、播放、网络共享、合并,播放器有Slider控制条。是基于j2se的练手项目,仅供下载者参考,请勿转载,谢谢合作。
MyMp3.rar
  • MyMp3
  • Mp3UI$12.class
    2.1KB
  • Mp3UI$13.class
    1.8KB
  • Mp3UI$8.class
    4KB
  • Mp3UI$19.class
    1.5KB
  • Mp3UI$1.class
    1.2KB
  • default.list
    0B
  • Mp3UI$5.class
    3KB
  • Mp3UI$9.class
    1.9KB
  • Mp3ShareServer.java
    2.5KB
  • Mp3UI$18.class
    1.4KB
  • Mp3ShareClient.java
    2.2KB
  • Mp3ShareServer.class
    1.4KB
  • Mp3UI$4.class
    3.5KB
  • SendMp3.class
    1.8KB
  • Mp3UI$2.class
    2.4KB
  • Mp3UI$14.class
    2.3KB
  • Mp3UI$16.class
    1KB
  • list.list
    8B
  • Mp3UI$15.class
    758B
  • ReceiveMp3.class
    2.4KB
  • Mp3UI$6.class
    2.5KB
  • Mp3UI.java
    37.5KB
  • Mp3UI$10.class
    3KB
  • Mp3ShareClient.class
    2KB
  • run.bat
    57B
  • Mp3UI$3.class
    3KB
  • Mp3UI.class
    14.9KB
  • Mp3UI$7.class
    1.6KB
  • Mp3UI$11.class
    2.4KB
  • Mp3UI$17.class
    904B
  • Mp3Player.java
    614B
  • Mp3Player.class
    1.1KB
  • jmf-2_1_1e-windows-i586.exe
    5MB
内容介绍
import javax.swing.*; import java.awt.*; import java.io.*; import java.util.*; import java.awt.event.*; import javax.media.*; public class Mp3UI extends JFrame implements Runnable { private static final long serialVersionUID = 1L; private JPanel jContentPane = null; private JMenuBar jJMenuBar = null; private JScrollPane jScrollPane = null; private JSlider songSlider = null; private JLabel showPlayingTimeLabel = null; private JLabel totalTimeLabel = null; private JList songList = null; private JButton stopButton = null; private JComboBox playStyle = null; private JScrollPane jScrollPane1 = null; private JList listList = null; private JLabel status = null; private Vector v = new Vector();//list lists private Vector vSong = new Vector();//list songs private String currentSongList; private Mp3Player mp3Player; private Mp3ShareServer mp3ShareServer; private String playingMp3Path,playingMp3Name; private int playingTime,totalTime,playingMapKeyIndex; private boolean skipTime; private String cutSongSavePath; private String mp3PlayerStyle = "播放模式"; private double beginCut,stopCut;//截取模式下的应用数据 private JMenuItem author,operation,knowMe,merge,share;//菜单选项 private JMenuItem mergeSong,shareSong;//对播放列表歌曲的操作,扩展功能 private Map<Integer,String> songMap = new HashMap<Integer,String>();//此Map用于保存歌曲列表歌曲的列表索引(key)和路径(value) public Mp3UI() { super(); initialize(); this.setVisible(true); this.setResizable(false); this.setDefaultCloseOperation(EXIT_ON_CLOSE); } private void initialize() { this.setSize(472, 425); this.setContentPane(getJContentPane()); this.setTitle("JFrame"); JMenuBar jmb = new JMenuBar(); JMenu jm1 = new JMenu("关于"); JMenu jm2 = new JMenu("帮助"); JMenu jm3 = new JMenu("扩展功能"); //about = new JMenuItem("作者"); //help = new JMenuItem("操作"); author = getAboutJMenuItemAuthor(); operation = getHelpJMenuItemOperation(); knowMe = getHelpJMenuItemKnowMe(); merge = getExtensionJMenuItemMerge(); share = getExtensionJMenuItemShare(); jm1.add(author); jm2.add(operation); jm2.add(knowMe); jm3.add(merge); jm3.add(share); jmb.add(jm1); jmb.add(jm2); jmb.add(jm3); this.setJMenuBar(jmb); } private JPanel getJContentPane() { if (jContentPane == null) { status = new JLabel(); status.setBounds(new Rectangle(2, 343, 179, 31)); status.setText("状态栏"); totalTimeLabel = new JLabel(); totalTimeLabel.setBounds(new Rectangle(137, 32, 49, 18)); totalTimeLabel.setText("总时间"); showPlayingTimeLabel = new JLabel(); showPlayingTimeLabel.setBounds(new Rectangle(7, 31, 81, 18)); showPlayingTimeLabel.setText("播放时间"); jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(getJScrollPane(), null); jContentPane.add(getSongSlider(), null); jContentPane.add(showPlayingTimeLabel, null); jContentPane.add(totalTimeLabel, null); jContentPane.add(getStopButton(), null); jContentPane.add(getPlayStyle(), null); jContentPane.add(getJScrollPane1(), null); jContentPane.add(status, null); } return jContentPane; } private JMenuBar getJJMenuBar() { if (jJMenuBar == null) { jJMenuBar = new JMenuBar(); } return jJMenuBar; } private JScrollPane getJScrollPane() { if (jScrollPane == null) { jScrollPane = new JScrollPane(); jScrollPane.setBounds(new Rectangle(180, 0, 283, 370)); jScrollPane.setViewportView(getSongList(null)); } return jScrollPane; } //滚动条控制器 private JSlider getSongSlider() { if (songSlider == null) { songSlider = new JSlider(); songSlider.setBounds(new Rectangle(0, 14, 178, 16)); //songSlider.setMajorTickSpacing(1); //songSlider.setPaintTicks(true); songSlider.setValue(0); songSlider.setMinimum(0); songSlider.setMaximum(100); songSlider.addMouseListener(new MouseAdapter() { public void mouseReleased( MouseEvent e) { if(mp3Player!=null) { songSlider.setMinimum(0); songSlider.setMaximum((int)mp3Player.getPlayer().getDuration().getSeconds()); playingTime = songSlider.getValue(); //多线程机制存在不同步现象 songSlider.setValue(playingTime); mp3Player.getPlayer().setMediaTime(new Time((double) playingTime)); skipTime = true; } } }); } return songSlider; } //播放列表 private JList getSongList(String listName) { songList = new JList(); songList.setBorder(BorderFactory.createTitledBorder(null,"歌曲列表")); songList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); currentSongList = listName; //vSong置空 if(listName != null) { int i = 0; for(;;) { if(vSong.size()!=0) { vSong.remove(i); continue; } break; } //置空songMap songMap.clear(); FileInputStream fis =null; DataInputStream dis=null; //列表刷新 try { fis = new FileInputStream(listName + ".list"); dis = new DataInputStream( fis); int j=0; String string; //由于采用readUTF()方式,文件结尾将会跳到Exception 段,代码段潜在不可测错误 while((string = dis.readUTF())!=null) { File song = new File(string); songMap.put(j, song.getAbsolutePath()); vSong.add(song.getName()); j++; //System.out.println("歌名:" +song.getName() +" vSong.size() = "+ vSong.size()); } fis.close(); dis.close(); j = 0; } catch (Exception e) { //e.printStackTrace(); //System.out.println("歌名:" +vSong); songList.setListData(vSong); songList.updateUI(); //System.out.println("读取结束!"); //由于会readUTF抛出异常进入此段,对流进行关闭 try { fis.close(); dis.close(); } catch (Exception e1) { e1.printStackTrace(); } } songList.setListData(vSong); //为歌曲列表添加侦听 songList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JPopupMenu pm = new JPopupMenu(); JMenuItem deleteSong = new JMenuItem("删除歌曲"); //JMenuItem renameSong = new JMenuItem("重命名歌曲"); JMenuItem cutSong = new JMenuItem("对此歌曲进行截取"); JMenuItem renameSong = new JMenuItem("重命名歌曲"); mergeSong = new JMenuItem("合并选中歌曲"); shareSong = new JMenuItem("分享歌曲"); pm.add(deleteSong); pm.add(renameSong); pm.add(cutSong); pm.add(mergeSong); pm.add(shareSong); //播放列表鼠标事件侦听 双击时播放音乐 songList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if( e.isMetaDown()&&listList.getSelectedIndex()!= -1) { pm.show(e.getComponent(),e.getX(), e.getY()); } if(e.getClickCount() == 2 &&listList.getSelectedIndex()!= -1 ) { playingMp3Path = songMap.get(songList.getSelectedIndex()); playingMp3Name = (String)songList.getSelectedValue(); playingMapKeyIndex = songList.getSelectedIndex(); if(mp3Player!=null&&mp3Player.getPlayer()!=null) { mp3Player.getPlayer().close(); } mp3Player = new Mp3Player( playingMp3Path); status.setText("正在播放:" + (String)songList.getSelectedValue()); //此处鼠标动作侦听冲突,不能重设slider值 //songSlider.setMinimum(0); //songSlider.setMaximum((int)mp3Player.getPlayer().getDuration().getSeconds()); songSlider.setValue(0); stopButton.setEnabled(true); } } }); //对播放列表歌曲的删除操作 deleteSong.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int
评论
    相关推荐
    • FreeMaker IDE
      FreeMarker的Eclipse插件,可以高亮显示FTL标签,提示语法错误,以及智能提示!
    • selenium ide
      selenium ide下载,fire path
    • IDE设置
      IDE设置
    • FreeMaker IDE
      FreeMaker IDE FreeMaker IDE
    • silabs ide
      用于调试51F023的软件 可以与CE3配套使用
    • ide
      ide
    • ide
      ide
    • IDE Factory
      【名称】IDE Factory 【作用】Flex Builder的AS3开发插件,主要用于生成Geter and Setter 、Format code...etc 【版本】Beta2 1.05(2008.12.20 最新) 【官网】开代理访问 www.idefactory.com 【已知Bug】 根据...
    • SiLabs IDE
      新华龙公司特别为C8051系列开发的编译软件IDE,界面很直观,非常好用!
    • Perl IDE
      一个Perl的程序设计器。