使用MediaRecorder录制视频,并进行播放

这篇博客介绍了从Android 1.6版本开始如何使用MediaRecorder录制视频,并在应用程序中播放。内容涵盖布局设计,包括一个包含按钮的LinearLayout和一个用于预览的VideoView。在onResume()和onPause()中处理照相机和MediaRecorder的初始化与释放,确保资源的有效管理。此外,提供了相关代码链接供读者参考。
摘要由CSDN通过智能技术生成

    自Android SDK 1.6 开始,录制视频需要将照相机所看到的内容预览到Surface对象上。采用真机测试。


布局文件:

<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:orientation="horizontal">

    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        >
        <Button 
            android:id="@+id/initBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Initialize Recorder"
            android:onClick="doClick"
            android:enabled="false"
            />
        <Button 
            android:id="@+id/beginBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Begin Recording"
            android:onClick="doClick"
            android:enabled="false"
            />
        <Button 
            android:id="@+id/stopBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Stop Recording"
            android:onClick="doClick"
            />
        <Button 
            android:id="@+id/playRecordingBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Play Recording"
            android:onClick="doClick"
            />
        <Button 
            android:id="@+id/stopPlayingRecordingBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Stop Playing"
            android:onClick="doClick"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值