基于android的音乐播放器_毕业论文(编辑修改稿)内容摘要:

为了存放音乐文件,需要自己创建 sdcard,我们先来看看如何创建 sdcard 以及文件上传。 SD 卡的创建 通过 Android 的 Tools 来创建 sd 卡并导入进来 1. 打开 dos, windows+R 键打开。 转换到你的 sdk 安装包的 tools 目录下,如我的目录如下: E:\androidsdkwindows\tools 2. 创建 sd卡。 在命令行中输入: mksdcard 1024M E:\androidsdcard\ (这个 1024M 就是我们要创建的 SD 卡的大小,还是根据自己的需要来输入,最后面的那个 E:\androidsdcard\ 就是所设置的 SD 存放路径,这里也可以根据我们自己的需要改变路径的,但 要注意路径中不能有空格出现) 14 3. 在 Eclipse 里面创建模拟器,并以该 SD 开来创建 4. 创建完成之后,启动该模拟器。 可以在 Android SDK and AVD Manager 里面指定模拟器并启动。 5. 同样打开 Eclipse 的 DDMSFile— Explorer 查看 sd 卡是否安装成功。 向 sd 卡里面上传文件及异常解决 右边两个小手机按钮就是传输文件的按钮了,用它来实现文件的传入和传出了,向左的表示把手机里的文件导出,向右的表示把文件导入到手机里面去。 这里和容易出现异常。 异常如下: 异常一: Failed to push selection: Invalid argument 出现此异常,多半是文件所在的目录里面有中文或者文件的名字是中文导致的。 建议修改一下试试。 还有就是观察自己的操作权限是不是不够,如果是,d— rwxr— x 那就是可以的。 如果, sd 卡是在 eclipse 里面系统自动创建的,试着重启一下 IDE。 异常二: Failed to push the item( s) 出现这个异常是因为传输超时造成的。 可以修改。 打开 windows— Preference— android— DDMS 把 ADB connection tine out 项的超时时间改大点。 15 3 音乐播放器的详细设计 播放器主界面的设计和说明 Android 的每一个可视化界面,都有其唯一的布局配置文件,该文件里面有各种布局方式,各种资源文件如图像,文字,颜色的引用,程序在运行时,可以通过代码对配置文件进行读取。 这样就可以形成不同的可视化界面和绚丽的效果。 主界面布局文件内容如下: ?xml version= encoding=utf8? AbsoluteLayout xmlns:android= android:id=@+id/AbsoluteLayout01 android:layout_width=wrap_content android:layout_height=fill_parent android:background=@drawable/backgrund android:sharedUserId= 此处的 ListView作用为列出歌曲 ListView android:id=@id/android:list android:layout_width=fill_parent android:layout_height=fill_parent android:layout_weight=1 android:drawSelectorOnTop=false/ LinearLayout android:layout_width=fill_parent android:layout_height=wrap_content android:gravity=center android:orientation=horizontal 此处的 ImageButton用于第一曲 ImageButton android:id=@+id/music_lasted android:layout_width=wrap_content android:layout_height=wrap_content android:layout_marginRight=5dp android:src=@drawable/latest1 / 此处的 ImageButton用于上一曲 ImageButton 16 android:id=@+id/music_rewind android:layout_width=wrap_content android:layout_height=wrap_content android:layout_marginRight=5dp android:src=@drawable/rewind / 此处的 ImageButton用于播放与暂停 ImageButton android:id=@+id/music_play android:layout_width=wrap_content android:layout_height=wrap_content android:layout_marginRight=5dp android:src=@drawable/play1 / 此处的 ImageButton用于下一曲 ImageButton android:id=@+id/music_foward android:layout_width=wrap_content android:layout_height=wrap_content android:layout_marginRight=5dp android:src=@drawable/foward / 此处的 ImageButton用于最后一曲 ImageButton android:id=@+id/music_next android:layout_width=wrap_content android:layout_height=wrap_content android:src=@drawable/next1 / /LinearLayout 主界面为: 17 Android 媒体播放原理 Android 源程序已经为我们封装了一个接口类,叫 MediaPlayer。 该接口在执行前需要一个数据源,通过如下四个步骤: 第一步: (); 复位操作,为以后的媒体准备播放做准备。 第 二 步 : 传 入 歌 曲 数 据 源 , 这 里 也 是 一 个 数 据 源 :(String path)。 参数需要一个路径,该接口类在收到路径后将其转化为数据源。 第三步:准备播放数据源,调用 ()。 第四步: ()。 播放数据源,该数据源播放后, 18 不再于程序有关,需要调用 ()方法让其停。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。