一、功能要求
在基于存储卡音乐播放器V0.2基础上,增加功能:
添加一个音乐播放列表(显示歌名)
– 单击某一首音乐就立刻播放,播放进度清零,显示当前音乐的播放时长。
添加一个【上一首】与【下一首】按钮----完成
– 当前音乐为第一首时,单击【上一首】按钮,切换到最后一首音乐。----完成
– 当前音乐为最后一首时,单击【下一首】按钮,切换到第一首音乐。----完成
– 当某一首音乐播放完毕后,会自动切换到下一首音乐播放。----完成
二、运行效果
实现步骤
将图片素材拷贝到drawable目录与mipmap目录
上一首按钮背景图片选择器 - previous_button_selector.xml
下一首按钮背景图片选择器 - next_button_selector.xml
主布局资源文件activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical"
android:padding="20dp"
tools:context=".ui.MainActivity">
<ListView
android:id="@+id/lvMusicName"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="16dp"
android:layout_weight="8" />
<TextView
android:id="@+id/tvMusicName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:textColor="#0000ff"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="0.5"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/tvCurrentPosition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="#ff0000" />
<ProgressBar
android:id="@+id/pbMusicProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_widt