网站导航网学 原创论文 网站设计 最新系统 最新研究 原创论文 获取论文 论文降重 发表论文 论文发表 UI设计定制 论文答辩PPT格式排版 期刊发表 论文专题
返回网学首页
网学原创论文
最新论文 推荐专题 热门论文 论文专题
当前位置: 网学 > 设计下载 > 其他类别 > 正文

基于J2SE的MP3播放器的设计与实现

来源:http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/05/06

本文主要为广大网友提供“基于J2SE的MP3播放器的设计与实现”,希望对需要基于J2SE的MP3播放器的设计与实现网友有所帮助,学习一下!

QQ交谈客服咨询,网学网竭诚为您服务,本站永久域名:myeducs.cn

 

1            系统的实现
这里将介绍本系统的技术重点、难点的设计与实现。在整个项目中,大量的运用了Java类库提供的功能,包括Java SWING的高级组件的使用,基于对象序列化(Object Serialization)的配置保存,基于DnD技术的拖放批量文件的播放等。
1.1      监听鼠标事件
对于在JList中鼠标的动作,系统要监听。比如说当在空的列表中双击时,要判断返回的index是否为-1(即非法),在点击的列表中有子项时,应该将返回的坐标转换成索引,然后根据索引在playList中找出对应的项[19];在列表中单击时,构造一个AudioMedia实例以完成添加到收藏夹的功能。
list.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent e) {
                           if (e.getClickCount() == 2) {
//将鼠标点击两次的位置转换成JList中的index
                                  index =list.locationToIndex(e.getPoint());
                                  if (index != -1 && index < playList.size()) {
//判断是否正在播放,如果正在播放则重新初始化Player和面板
                                         if (isPlaying) {
                                                if (audioPlayer != null) {
                                                       audioPlayer.stop();
                                                       playPanel.removeAll();
                                                       audioPlayer.close();
                                                }
                                         }
                                         try {
//根据index从playList取出相应的AudioMedia并构造出一个Player对象
             audioPlayer = Manager.createRealizedPlayer(((AudioMedia) playList
             .get(index)).getFileURL());
                                                am = (AudioMedia) playList.get(index);
       //如果未加入最近播放列表,则加入到最新列表当中
                                                if (!rm.alreadyInRecent(am)) {
 
                                                       // am.setInRecent(true);
                                                       rm.addToRecent(am);
                                                }
                                                isPlaying = true;
                                                audioPlayer.addControllerListener(PSL);
                                                Component controlComponent = audioPlayer
                                                              .getControlPanelComponent();
                                                playPanel
                                                              .add(BorderLayout.CENTER, controlComponent);
                                                playPanel.setBorder(BorderFactory
                                                              .createLineBorder(Color.blue));
                                                cp.add(BorderLayout.SOUTH, playPanel);
                           //重新刷新面板
                                                cp.validate();
                                                // start the player
                                                audioPlayer.start();
                                         } catch (FileNotFoundException e1) {
                                                JOptionPane.showMessageDialog(null,
                                                              "Can''t find the file!");
                                         } catch (IOException e2) {
                                                JOptionPane.showMessageDialog(null,
                                                              "Can''t open the file!");
                                         } catch (NoPlayerException e3) {
                                                JOptionPane.showMessageDialog(null,
                                                              "No Player");
                                         } catch (CannotRealizeException e4) {
                                                JOptionPane.showMessageDialog(null,
                                                              "Can''t realize");
                                         }
                                  } else {
                                         System.out.println("null");
                                  }
                           }
     //如果仅点击一次,则只重新构造出一个AudioMedia对象
                           if (e.getClickCount() == 1) {
                                  index = list.locationToIndex(e.getPoint());
                                  if (index != -1 && index < playList.size()) {
                                         am = (AudioMedia) playList.get(index);
                                  } else {
                                         System.out.println("null");
                                  }
                           }
                     }
             });
本站发布的计算机毕业设计均是完整无错的全套作品,包含开题报告+程序+论文+源代码+翻译+答辩稿PPT

本文选自计算机毕业设计http://myeducs.cn
论文文章部分只是部分简介,如需了解更多详情请咨询本站客服!QQ交谈QQ3710167

原创论文

设为首页 | 加入收藏 | 论文首页 |原创论文 |
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2020 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号 常年法律顾问:王律师