基于android普通的音乐播放器的设计与实训软件技术毕业论文

上传人:a**** 文档编号:139144876 上传时间:2022-08-22 格式:DOC 页数:28 大小:1.91MB
收藏 版权申诉 举报 下载
基于android普通的音乐播放器的设计与实训软件技术毕业论文_第1页
第1页 / 共28页
基于android普通的音乐播放器的设计与实训软件技术毕业论文_第2页
第2页 / 共28页
基于android普通的音乐播放器的设计与实训软件技术毕业论文_第3页
第3页 / 共28页
资源描述:

《基于android普通的音乐播放器的设计与实训软件技术毕业论文》由会员分享,可在线阅读,更多相关《基于android普通的音乐播放器的设计与实训软件技术毕业论文(28页珍藏版)》请在装配图网上搜索。

1、 编号 xxx信息职业技术学院毕业论文题 目基于Android普通的音乐播放器的设计与实训学生姓名xx学 号xxx院 系 计算机与通信工程学院专 业软件技术班 级xx指导教师xx顾问教师二一六年六月摘 要本音乐播放器的开发的原因是,在当今大众娱乐的时代,音乐播放器已是越来越不可少,开发这个项目可以方便很多人。Android当前发展前景很不错,特别是在中国市场,中国智能 用户花钱购买应用程序的意识淡薄,安卓主打免费和开放式系统,适合广大人群,安全系数一般,虽然没有IOS那样稳定易用,但开发前景仍然可观。随着社会的进步发展,人们生活水平的稳健提高,越来越多的人们开始对娱乐生活有着各种各样的需求,其

2、中,音乐以其独特的律动和韵味捕获了大多数人们的心。在这样的时代中,音乐播放器的使用也显得格外的讲究。本音乐播放器为满足广大用户对音乐体验的快感,结合了主流播放器的基本功能,并大胆创新,只为给广大用户带来极致的音乐享受。本音乐播放器基本实现了现如今主流音乐播放器的基本功能,基本符合大众对音乐播放器的需求。除此以外,本播放器还提供了下载功能以及波形图,左右声道等新鲜功能。满足各类用户的需求,带来前所未有的体验感。关键词1.AbstractThe reason for the development of the music player is that in the era of mass ent

3、ertainment, music player is becoming more and more indispensable, the development of this project can be convenient for many people. Android is currently the development prospects are very good, especially in the Chinese market, Chinese smartphone users spend money to buy application consciousness,

4、Android main free and open system, suitable for the majority of the population, the factor of safety in general, although there is no IOS as stable and easy to use, but the prospects are still impressive.With the social progress and development, peoples living standards improve the robustness of the

5、, more and more people began to have a variety of demand for live entertainment, including music, with its unique rhythm and charm capture the heart of most people. In such an era, the use of music players also appears to be particularly stress.The music player to meet the majority of users of the m

6、usic experience of pleasure, combined with the basic features of the mainstream player, and bold innovation, only for the majority of users to bring the ultimate music to enjoy.The basic realization of the music player is now the mainstream music players basic functions, basically in line with the n

7、eeds of the public music player. In addition, the player also provides download features as well as the waveform, the left and right channels, and other new features. Meet the needs of all kinds of users, bring an unprecedented sense of experience.Keywords:1.android 2. music player 3.Download functi

8、on目 录摘 要IABSTRACTII第一章 绪论11.功能设计1111112. 本论文的内容和结构说明1第二章 系统设计32.1系统面向对象设计32.2数据库设计32.3主界面设计4第三章 系统实现53.1数据库存储系统的实现53.2系统功能实现53.2.1音乐信息添加功能的实现53.2.2音乐列表更改功能的实现63.2.3服务器音乐下载功能的实现73.2.4设置功能的实现9“关于”实现123.2.6通知栏音乐播放控制功能的实现133.2.7双声道和波形功能的实现14第四章 软件系统测试17测试目的17测试对象及测试范围17第五章 总结与展望18致 谢19参考文献20附录 项目类表21第一章

9、 绪论 通过该模块,用户可以实现对音乐播放的管理,主要功能包括:a. 播放/暂停:用户可以通过此功能对音乐实施播放或暂停控制。b. 上一首:用户可以通过此功能切换音乐至上一首。c. 下一首:用户可以通过此功能切换音乐至下一首。d. 播放模式:用户可以通过此功能调节播放模式,包括顺序播放、循环播放和随机播放。e. 进度条拖动:用户可以通过此功能调节音乐的播放进度。a. 播放/暂停:用户可以通过此功能对音乐实施播放或暂停控制。b. 上一首:用户可以通过此功能切换音乐至上一首。c. 下一首:用户可以通过此功能切换音乐至下一首。d. 关闭:用户可以通过此功能直接关闭播放器。e. 跳转:用户可以通过此功

10、能从通知栏跳转至主界面。a. 默认列表:用户打开列表自动搜索内存里的音乐,并导入默认列表。用户可通过此列表进行选择播放。b. 喜欢列表:用户通过在默认列表中的选择,将喜欢的音乐导入喜欢列表。用户可通过此列表进行选择播放。c. 下载列表:用户可通过网络下载喜欢的音乐至此列表,并进行选择播放。a. 背景设置:用户可通过此功能更换界面背景。b. 搞怪3D音效:用户可通过此功能获取搞怪音效。c. 语言设置:用户可通过此功能来进行中英文切换。a. 用户如果没有插入耳机,则出现波形图。b. 用户如果插入耳机,则进行双声道管理。2. 本论文的内容和结构说明软件设计采用IAR C语言软件开发系统,通过系统通讯

11、主程序、路由子程序、传感器信号采集处理子程序、显示报警子程序等模块化软件设计,设计出使用简便、运行效率高、稳定可靠的配套软件系统。本文结构主要由绪论、音乐播放器的构成与组建、系统模块的介绍,流程图和关键代码实现。第1章:绪论,介绍音乐播放器的功能设计。第2章:系统设计,系统总体分析与设计,总体介绍项目的构成。第3章:系统实现的原理。第4章:系统测试。第5章:对项目的以后的展望和。系统顶层用例图如图1:图1 系统用例图第二章 系统设计根据系统的需求分析,各功能模块所涉及的类如下:音乐列表类:功能:修改音乐类型信息,比如添加音乐数据、查询所有未被删除的音乐信息、添加删除喜欢音乐。属性:存储音乐类型

12、信息,比如默认音乐类型有歌曲ID、名称、专辑名、歌手名、路径、播放时长、大小、重命名歌曲名等。音乐列表类图如图图2.1 音乐列表类图系统采用SQLite关系型数据库进行数据库设计,由系统对象关系分析可知,系统数据存储结构可由一张数据表构成,其具体结构如表1所示。表1 音乐类型信息表表名account_type_info列名数据类型非空描述主键外键idintegerY歌曲IDYtitletext歌曲的名称 albumtext歌曲的专辑名artisttext歌曲的歌手名urltext歌曲文件的路径durationtext歌曲的总播放时长musicnametext重命名歌曲名sizetext歌曲文件

13、的大小statusinteger1标识不喜欢,2标识喜欢由于采用移动手持终端作为应用程序载体,为提高人机交互效果,主界面宜采用扁平化设计。可以更加简单直接的将信息和事物的工作方式展示出来,减少认知障碍的产生。主界面设计如图所示。 图2.3 主界面设计第三章 系统实现本存储系统利用Andorid的SQLite关系型数据库存储系统实现。其数据表字段及数据表创建等核心代码如下所示:数据表字段代码:private SQLiteDatabase mMusicListdb = null;private final String LIST_DBNAME = music_list;private final

14、String TBL_MUSIC = tbl_music;private final String TITLE = tilte;private final String ALBUM = album;private final String ARTIST = artist;private final String URL = url;private final String DURATION = duration;private final String SIZE = size;private final String MUSICNAME = musicname;private final St

15、ring STATUS = status;本音乐播放系统通过播放、音效、设置、关于、通知等其他系统共同实现。主界面以下功能:播放、列表、设置、关于。1. 播放:音乐的播放控制;2. 列表:音乐列表显示和更改;3. 设置:更改背景、语言设置和3D音效;4. 双声道和波形;5. 关于;6. 通知栏音乐播放管理。该功能主要是音乐信息的添加,点击主界面的列表按钮,打开音乐默认列表自动添音乐(如图3.1所示)。弹出等待提示框(如图3.2所示),音乐添加完成后将自动关闭并刷新列表。图3.1 音乐信息添加 图3.2 等待提示框添加音乐数据访问层(MusicListDao类)核心代码:public void

16、initData(SdcardMusic sm)ContentValues cv = new ContentValues();cv.put(TITLE, sm.getTilte();cv.put(ALBUM, sm.getAlbum();cv.put(ARTIST, sm.getArtist();cv.put(URL, sm.getUrl();cv.put(DURATION, sm.getDuration();cv.put(SIZE, sm.getSize();cv.put(MUSICNAME, sm.getMusicname();cv.put(STATUS, 1);mMusicListdb.

17、insert(TBL_MUSIC, novalue, cv);mMusicListdb.close();添加音乐信息事件核心代码:if(new MusicListDao(view.getContext().findAllMusic().isEmpty()if(new MusicListDao(view.getContext().findAllMusic().isEmpty()showLoadDialog(false);new Thread()public void run() Vector als = new Vector();als = CommonUtils.getMusicFromSdC

18、ard(view.getContext();for(int i=0;i 30000)new MusicListDao(view.getContext().initData(als.elementAt(i);hand.sendEmptyMessage(0);.start();elseToast.makeText(view.getContext(), R.string.application_no_music, Toast.LENGTH_SHORT).show();功能的实现该功能主要是负责音乐列表的查询和修改,点击默认列表界面的钻石图标,可将该音乐添加至我喜欢的音乐列表(如图3.3所示),选择右

19、侧黄色标签可查看不同列表(如图3.4所示)。图3.3 添加至喜欢的音乐列表查询音乐信息数据访问层(MusicListDao类)核心代码public Vector findAllMusic()Vector vsm = new Vector();Cursor c = mMusicListdb.rawQuery(select * from +TBL_MUSIC + where + STATUS + ?, new String0);t();while(!c.isAfterLast()SdcardMusic sm = new SdcardMusic();sm.setId(c.getInt(0);sm.s

20、etTilte(c.getString(1);sm.setAlbum(c.getString(2);sm.setArtist(c.getString(3);sm.setUrl(c.getString(4);sm.setDuration(c.getInt(5);sm.setSize(c.getInt(6);sm.setMusicname(c.getString(6);sm.setStatus(c.getInt(8);vsm.addElement(sm);c.moveToNext();return vsm;服务器音乐下载功能的实现点击列表内的下载按钮可从服务器下载该音乐至本地(如图所示)。等待下载

21、完成后即可播放(如图3.6所示)。 图3.5 下载音乐至本地 图3.6 下载完成客户端连接接收代码public static String IP = 192.168.191.2;public static int PORT = 5000;public static String music_title = Your Smile.mp3;public boolean connect()new Thread() public void run() try while (true) Socket socket = new Socket(IP , PORT);String local_file = E

22、nvironment.getExternalStorageDirectory().getAbsolutePath() + /AdownloadMusic/;File f = new File(local_file);if (!f.exists() f.mkdirs();local_file = f.getAbsolutePath() + / + music_title;File file = new File(local_file);InputStream ins = socket.getInputStream();FileOutputStream fos = new FileOutputSt

23、ream(file);BufferedInputStream bis = new BufferedInputStream(ins);BufferedOutputStream bos = new BufferedOutputStream(fos);byte buffer = new byte102400;int len = bis.read(buffer);while (len != -1) bos.write(buffer, 0, len);len = bis.read(buffer);fos.flush();fos.close();FileReader fr = new FileReader

24、(file);String str = ;int val = ins.read(buffer);val = fr.read();while (val != -1) str += (char) val;val = fr.read();CommonData.downloading = 0;CommonData.handler_deletemusic.sendEmptyMessage(2); catch (Exception e) CommonData.downloading = 0;CommonData.handler_deletemusic.sendEmptyMessage(3);.start(

25、);return false;服务端创建服务传输代码public static void main(String args) File file = new File(Your Smile.mp3);try ServerSocket socketServerSocket = new ServerSocket(5000,1,InetAddress.getByName(172.17.0.82);while(true)Socket socket = socketServerSocket.accept();try OutputStream ops = socket.getOutputStream();

26、BufferedOutputStream bos = new BufferedOutputStream(ops);BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file);byte buffer = new byte102400;int len = bis.read(buffer);while(len != -1)bos.write(buffer,0,len);len = bis.read(buffer);bos.flush();bos.close();ops.flush();ops.close();

27、System.out.println(ok!);Thread.sleep(1000); catch (Exception e) e.printStackTrace(); catch (Exception e) e.printStackTrace();的实现点击主界面的设置按钮即可调出设置菜单(如图3.7);点击背景设置按钮弹出背景选择界面长按即可设置成功(如图3.8);图3.7 设置菜单查看图3.8 背景设置成功背景设置关键代码public class ImageAdapter extends BaseAdapter private int mGalleryItemBackground;pri

28、vate Context context;public ImageAdapter(Context context) this.context = context;TypedArray typedArray = context.obtainStyledAttributes(R.styleable.Gallery);mGalleryItemBackground = typedArray.getResourceId(R.styleable.Gallery_android_galleryItemBackground, 0);typedArray.recycle(); Overridepublic in

29、t getCount() return myImageIds.size();Overridepublic Object getItem(int position) return position;Overridepublic long getItemId(int position) return position;public View getView(int position, View convertView, ViewGroup parent) ImageView i = new ImageView(context);i.setImageResource(myImageIds.eleme

30、ntAt(position%myImageIds.size();i.setId(myImageIds.elementAt(position%myImageIds.size();i.setScaleType(ImageView.ScaleType.FIT_XY);i.setLayoutParams(new Gallery.LayoutParams(800, 450); i.setBackgroundResource(mGalleryItemBackground);return i;点击语言设置按钮可选择语言(如图3.9);点击搞怪3D音效可开启3D音模式(如图3.10)。 图 3.9语言设置 图

31、3.10 3D音模式语言设置功能关键代码btn_lan_set.setOnClickListener(new OnClickListener() Overridepublic void onClick(View v) ETTINGS);startActivity(intent););3D音效模式关键代码private Timer mtm = null;private TimerTask mttk = null;private void SetSimulationSound(boolean aa)try final Random rd = new Random();mp.setVolume(0.

32、5F,0.5F);if(aa)mtm = new Timer();mttk = new TimerTask() float v = 0.5f;public void run() if(mp.isPlaying()float a = rd.nextFloat();if(a 0.5)v = upleftSound(v);elsev = uprightSound(v);mtm.schedule(mttk, 0, 3000);elsemtm.cancel();mttk.cancel();mp.setVolume(1.0F,1.0F); catch (Exception e) private float

33、 upleftSound(float left)try float right = 1-left;for(int i=0; i150; i+)if(left 0.91)left+=0.01f;right = 1-left;mp.setVolume(left, right);Log.e(sss, left=+left);Thread.sleep(20);return left; catch (InterruptedException e) Log.e(sss, volume left change is error, e);return 0.5f;private float uprightSou

34、nd(float left)try float right = 1-left;for(int i=0; i 0.09)left-=0.01f;right = 1-left;mp.setVolume(left, right);Log.e(sss, left=+left);p(20);return left; catch (InterruptedException e) Log.e(sss, volume right change is error, e);return 0.5f;“关于”实现该功能主要是声明“ACG BOX”的版权,点击主界面的关于按钮,打开关于窗口(如图3.11所示),显示关于

35、“ACG BOX”。 图3.11 关于“ACG BOX”Diolog打开动画关键代码Overridepublic void onActivityCreated(Bundle savedInstanceState) super.onActivityCreated(savedInstanceState);getDialog().getWindow().getAttributes().windowAnimations = R.style.dialogAbout;getDialog().setCanceledOnTouchOutside(true); 打开,关闭调用的XML文件 使用的Style方法

36、anim/anim_showabout anim/anim_closeabout 通知栏音乐播放控制功能的实现打开通知栏点击即可跳转到当前软件主界面,4个按钮分别对应上一首、暂停/播放、下一首和关闭的功能(如图3.12)。 图3.12 通知栏音乐播放控制实现通知栏音乐播放控制关键代码private NotificationManager showCustomView() RemoteViews remoteViews = new RemoteViews(getPackageName(),R.layout.new_music_notification);remoteViews.setTextVi

37、ewText(R.id.title_title, CommonData.all_music.elementAt(PlayMusic.itemId).getTilte();remoteViews.setTextViewText(R.id.txt_duration, MyTimeUtils.Ms2mmss(CommonData.all_music.elementAt(PlayMusic.itemId).getDuration();remoteViews.setTextViewText(R.id.txt_artist, CommonData.all_music.elementAt(PlayMusic

38、.itemId).getArtist();Intent reActivity=new Intent(this,MainActivity.class);PendingIntent pIntent=PendingIntent.getActivity(this, 0, reActivity, 0);remoteViews.setOnClickPendingIntent(R.id.ll_parent, pIntent); Intent preintent = new Intent(); preintent.putExtra(action, last);preintent.setAction(org.w

39、y.playerReceiver);PendingIntent prepi = PendingIntent.getBroadcast(this, 0, preintent, PendingIntent.FLAG_UPDATE_CURRENT);remoteViews.setOnClickPendingIntent(R.id.last_music, prepi);if(CommonData.playstatus.flag_play = CommonData.playstatus.PLAY)Intent pauaseOrStartIntent=new Intent(); pauaseOrStart

40、Intent.putExtra(action, pause);pauaseOrStartIntent.setAction(org.wy.playerReceiver);PendingIntent pausepi = PendingIntent.getBroadcast(this, 1, pauaseOrStartIntent, PendingIntent.FLAG_UPDATE_CURRENT);remoteViews.setOnClickPendingIntent(R.id.paly_pause_music, pausepi);remoteViews.setImageViewResource

41、(R.id.paly_pause_music, R.drawable.btn_tostart);elseIntent pauaseOrStartIntent=new Intent(); pauaseOrStartIntent.putExtra(action, playing);pauaseOrStartIntent.setAction(org.wy.playerReceiver);PendingIntent pausepi = PendingIntent.getBroadcast(this, 2, pauaseOrStartIntent, PendingIntent.FLAG_UPDATE_C

42、URRENT);remoteViews.setOnClickPendingIntent(R.id.paly_pause_music, pausepi);remoteViews.setImageViewResource(R.id.paly_pause_music, R.drawable.btn_topause);Intent nextIntent=new Intent(); nextIntent.putExtra(action, next);nextIntent.setAction(org.wy.playerReceiver);PendingIntent nextpi=PendingIntent

43、.getBroadcast(this, 3, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT);remoteViews.setOnClickPendingIntent(R.id.next_music, nextpi);Intent closeIntent=new Intent(); closeIntent.putExtra(action, close_noti);closeIntent.setAction(org.wy.playerReceiver);PendingIntent closepi=PendingIntent.getBroadcast(t

44、his, 4, closeIntent, PendingIntent.FLAG_UPDATE_CURRENT);remoteViews.setOnClickPendingIntent(R.id.close, closepi);Builder builder = new Builder(MainService.this);builder.setContent(remoteViews).setSmallIcon(R.drawable.icon).setOngoing(true).setTicker(music is playing);Notification notification=builde

45、r.build();NotificationManager manager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);manager.notify(1, notification);return manager;双声道和波形功能的实现点击左上角即可调出波形界面(如图3.13);插上耳机后点击左上角弹出双声道界面(如图 3.14)。图3.13 通波形界面图3.14 双声道界面波形显示关键代码Override protected void onDraw(Canvas canvas) super.onDra

46、w(canvas); if (mBytes = null) return; if (mPoints = null | mPoints.length mBytes.length * 4) mPoints = new floatmBytes.length * 4; mRect.set(0, 0, getWidth(), getHeight(); for (int i = 0; i 0)if(mp.equals(mp_left)if(!source_left.equals(vsm.get(left_play).getUrl()try mp.reset();mp.setDataSource(vsm.g

47、et(left_play).getUrl();if (!mp.isPlaying() mp.prepare(); catch (Exception e) Log.e(sss, onStart mp_left - is error, e);source_left = vsm.get(left_play).getUrl();elseif(!source_right.equals(vsm.get(right_play).getUrl()try mp.reset();mp.setDataSource(vsm.get(right_play).getUrl();if (!mp.isPlaying() mp

48、.prepare(); catch (Exception e) Log.e(sss, onStart mp_right - is error, e);source_right = vsm.get(right_play).getUrl();elseToast.makeText(this, R.string.no_music, Toast.LENGTH_LONG).show();第四章 软件系统测试测试目的对基于Android应用开发系统的学习,对系统的各项功能进行检测,查看是否完成了设计文档中应有的模块并且检查模块的运行情况,检查出软件中还存在的问题予以修正,使系统最终能予以交付。测试对象及测试范围表1 测试范围测试项测试内容系统初始化本地数据库及服务是否能正常初始化主界面播放功能主界面是否能正常显示及控制音乐的播放通知栏播放功能通知栏界面是否能正常显示及控制音乐的播放列表添加各列表是否能正常显示及添加至列表中下载功能是否能连接服务端及下载相关音乐背景设置是否能切换背景语言设置各功能之间切换及数据传递是否正常波形图是否随音乐正常显示波

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!