近来项目中有播放音频的需求,于是想用MediaPlayer先写个Demo;
布局代码如下:
<?xml version="1.0" encoding="utf-8"?> <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:gravity="center" android:orientation="vertical" > <Button android:id="@+id/start" android:layout_height="wrap_content" android:layout_width="match_parent" android:text="开始" android:textAllCaps="false" android:textSize="25sp" /> <Button android:id="@+id/pause" android:layout_width="match_paren