设为首页 加入收藏

TOP

Android开发之打开闪光灯录制视频(二)
2015-07-16 12:57:40 来源: 作者: 【 】 浏览:44
Tags:Android 开发 打开 闪光灯 录制 视频
layout_height="wrap_content"
? ? ? ? ? ? android:minHeight="40dp"
? ? ? ? ? ? android:minWidth="70dp"
? ? ? ? ? ? android:text="录制" />


? ? ? ? ? ? ? ? ? ? android:id="@+id/rv_stop"
? ? ? ? ? ? style="@style/mainactivitybtnstyle"
? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:layout_marginLeft="10dip"
? ? ? ? ? ? android:minHeight="40dp"
? ? ? ? ? ? android:minWidth="70dp"
? ? ? ? ? ? android:text="停止" />
? ?


? ? ? ? ? ? android:layout_width="fill_parent"
? ? ? ? android:layout_height="fill_parent"
? ? ? ? android:gravity="center_horizontal"
? ? ? ? android:orientation="vertical" >


? ? ? ? ? ? ? ? ? ? android:id="@+id/rv_schedule"
? ? ? ? ? ? style="?android:attr/progressBarStyleHorizontal"
? ? ? ? ? ? android:layout_width="fill_parent"
? ? ? ? ? ? android:layout_height="wrap_content" />


? ? ? ? ? ? ? ? ? ? android:id="@+id/rv_record_time"
? ? ? ? ? ? android:layout_width="fill_parent"
? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? android:gravity="center"
? ? ? ? ? ? android:text="00:00:000"
? ? ? ? ? ? android:textColor="#FF750000"
? ? ? ? ? ? android:textSize="24sp"
? ? ? ? ? ? android:textStyle="bold" />
? ?



Activity代码,因为非常简单,就没有封装多线程什么的。


import java.io.File;
import java.text.SimpleDateFormat;


import android.content.Context;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;


import com.ict.util.IOUtil;


public class RecordVideoActivity extends ActionBarActivity {
? ? private static final String TAG = "RecordVideo";
? ? private SurfaceView surfaceView;
? ? private MediaRecorder mediaRecorder;
? ? private boolean record;? ?
? ? private TextView testusername;
? ? private Camera camera;
? ?
? ? // 计时器相关
? ? private MyChronograph myChronograph;
? ? private TextView chronograph = null;
? ?
? ? private ProgressBar schedule;
? ? private boolean recordOver = false;
? ?
? ? @Override
? ? protected void onCreate(Bundle savedInstanceState) {
? ? ? ? // TODO Auto-generated method stub
? ? ? ? super.onCreate(savedInstanceState);
? ? ? ? setContentView(R.layout.recordvideo);
? ? ? ? setTitle("录制视频");
? ? ? ? mediaRecorder = new MediaRecorder();
? ? ? ? surfaceView = (SurfaceView) this.findViewById(R.id.surfaceView);
? ? ? ? this.surfaceView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
? ? ? ? this.surfaceView.getHolder().setFixedSize(320, 240);//设置分辨率


? ? ? ? testusername = (EditText)findViewById(R.id.rv_testusername);
? ? ? ? chronograph = (TextView)findViewById(R.id.rv_record_time);
? ? ? ? schedule = (ProgressBar)findViewById(R.id.rv_schedule);
? ? ? ? schedule.setMax(60);
? ? ? ? ButtonClickListener listener = new ButtonClickListener();
? ? ? ? Button stopButton = (Button) this.findViewById(R.id.rv_stop);
? ? ? ? Button recordButton = (Button) this.findViewById(R.id.rv_record);
? ? ? ? stopButton.setOnClickListener(listener);
? ? ? ? recordButton.setOnClickListener(liste

首页 上一页 1 2 3 4 5 6 下一页 尾页 2/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android平台之不预览获取照相机预.. 下一篇Android设置选项开发及自定义Pref..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: