MediaRecorder
这个类主要用来做多媒体录音和录视频的
首先是录制视频的mainActivity.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8">
<SurfaceView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/surfaceview"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<Button
android:id="@+id/stop"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="暂停"
android:layout_weight="1"/>
<Button
android:id="@+id/start"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="开始"
android:layout_weight="1"/>
<Button
android:id="@+id/starting"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="播放"
android:onClick="btnClick"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
然后是录制视频的MainActivity类
这个类中有一个if判断这个判断是用来获取Android 6.0以上版本的动态权限
public class MainActivity extends AppCompatActivity implements Surfac