本文实例为大家分享了Android媒体开发之音乐播放器的具体代码,供大家参考,具体内容如下
可以对音乐文件实现播放、暂停、重播和停止功能。退出应用和回到桌面时音乐停止。
主界面:
主界面配置文件mian.xml:
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.musicplay.MainActivity" >
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/filename" />
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.00"
android:background="#B0C4DE"
android:text="Payphone.mp3"
android:id="@+id/filename" />
android:layout_width="fill_parent"
android:l