Android UI(7)Building Apps with Multimedia - Capturing Photo
2. Recording Videos Simply
Request Camera Permission
<uses-featureandroid:name="android.hardware.camera"/>
<uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Record a Video with a Camera App
//The widget of video
private VideoView videoView;
//current pos of the video file
private static int currentPosition = 0;
//video URI
private Uri videoUri;
publicvoid onCreate(Bundle savedInstanceState) {
Log.d(TAG, "entering the onCreate..."); super.onCreate(savedInstanceState); setContentView(R.layout.video_camera);
videoView = (VideoView) findViewById(R.id.video_window); Button vidBtn = (Button) findViewById(R.id.video_start); setBtnListenerOrDisable(vidBtn, mTakeVidOnClickListener,MediaStore.ACTION_VIDEO_CAPTURE); MediaController controller = new MediaController(this); videoView.setMediaController(controller); videoView.setOnPreparedListener(new OnPreparedListener() { public void onPrepared(MediaPlayer mp) { videoView.setBackgroundColor(Color.argb(0, 0, 255, 0)); } });
videoView.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) { Toast.makeText(VideoCameraActivity.this, "The End.",Toast.LENGTH_LONG).show(); } });
}
Send the intent to the camcorder, and prepare and bind the MediaController to the videoView.
View the Video
protectedvoid onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) { Log.d(TAG, "entering the call back..."); videoUri = data.getData(); videoView.setVideoURI(videoUri); videoView.requestFocus(); }
}
That is the callback method of the camcorder application.
Other state and restate method
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.d(TAG, "entering the onKeyDown..."); if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { finish(); return true; } return false; }
Button.OnClickListener mTakeVidOnClickListener = new Button.OnClickListener() { public void onClick(View v) { Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(takeVideoIntent, VIDEO_REQUEST); } };
protected void onSaveInstanceState(Bundle outState) { Log.d(TAG, "entering the onSaveInstanceState..."); outState.putParcelable(VIDEO_STORAGE_KEY, videoUri); super.onSaveInstanceState(outState); }
protected void onRestoreInstanceState(Bundle savedInstanceState) { Log.d(TAG, "entering the onRestoreInstanceState..."); super.onRestoreInstanceState(savedInstanceState); videoUri = savedInstanceState.getParcelable(VIDEO_STORAGE_KEY); videoView.setVideoURI(videoUri);
//videoView.setVideoPath(URL of the video file) videoView.requestFocus();
}
That is it, a simple video demo. videoView.setVideoPath(URL_PATH). Maybe in the future, I need this statement.
References:
http://developer.android.com/training/camera/videobasics.html
customer android player
http://www.360doc.com/content/11/0309/11/474846_99476781.shtml
http://easymorse.googlecode.com/svn/trunk/
http://easymorse.googlecode.com/svn/trunk/android.customer.player/
分享到:
相关推荐
官方离线安装包,亲测可用
1、文件内容:redhat-lsb-submod-multimedia-4.1-27.el7.centos.1.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/redhat-lsb-submod-multimedia-4.1-27.el7....
qtmultimedia-everywhere-src-6.6.0.zip
Python Multimedia - Beginner&.pdf
qtmultimedia-everywhere-src-6.6.0.tar.xz
"qt5-qtmultimedia-devel-5.6.0-1.nd7.3.x86_64.rpm"是一个针对NVIDIA Development Platform 7.3 (ND7.3)的RPM软件包,用于x86_64架构的系统。这个包是专门为开发人员设计的,包含了Qt5多媒体模块的开发头文件、库和...
Multimedia Geotagging This repository contains the implementation of algorithms that estimate the geographic location of multimedia items based on their textual content. The approach is described in ...
1、文件内容:qt5-qtmultimedia-examples-5.9.7-1.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/qt5-qtmultimedia-examples-5.9.7-1.el7.tar.gz #Step2、...
1、文件内容:qt5-qtmultimedia-doc-5.9.7-1.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/qt5-qtmultimedia-doc-5.9.7-1.el7.tar.gz #Step2、进入解压后...
1、文件内容:qt5-qtmultimedia-devel-5.9.7-1.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/qt5-qtmultimedia-devel-5.9.7-1.el7.tar.gz #Step2、进入...
CSR-BlueCore5-Multimedia-External-CS-101568-DSP4(蓝牙多媒体芯片-csr-bc05-mm)原理图
1、文件内容:qt5-qtmultimedia-5.9.7-1.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/qt5-qtmultimedia-5.9.7-1.el7.tar.gz #Step2、进入解压后的目录,...
官方离线安装包,亲测可用
官方离线安装包,亲测可用
Get hands-on experience with Apple’s Swift programming language by building real working apps. With this practical guide, skilled programmers with little or no knowledge of Apple development will ...
Anybody can start building multimedia apps for the Android platform, and this book will show you how! Now updated to include both Android 4.4 and the new Android L, Android Apps for Absolute Beginners...
Introduction To Computing And Programming With Java - A Multimedia Approach (2006),英文书籍,仅供个人参考,谢绝商业用途。
Learning Swift: Building Apps for macOS, iOS, and Beyond by Paris Buttfield-Addison English | 30 Mar. 2017 | ASIN: B06XYGFYQT | 516 Pages | AZW3 | 8.92 MB Get valuable hands-on experience with Swift ...