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/
分享到:
相关推荐
官方离线安装包,亲测可用
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 ...
CSR-BlueCore5-Multimedia-External-CS-101568-DSP4(蓝牙多媒体芯片-csr-bc05-mm)原理图
在本次讨论的文件 `qt5-qtmultimedia-examples-5.9.7-1.el7.x64-86.rpm.tar.gz` 中,包含了Qt5 QtMultimedia模块的示例程序及相关依赖文件。这个压缩包为 RPM 格式,它是一种在基于 RPM 的 Linux 发行版上打包和分发...
首先,文档介绍了压缩包中包含的内容,具体来说,包括了名为"qt5-qtmultimedia-doc-5.9.7-1.el7.noarch.rpm"的文档组件安装包以及其他一些依赖组件,如"qt5-qtdeclarative-5.9.7-1.el7.x86_64.rpm"、"qt5-...
官方离线安装包,亲测可用
官方离线安装包,亲测可用
在本例中,文件为“qt5-qtmultimedia-devel-5.9.7-1.el7.x64-86.rpm.tar.gz”,这是一份RPM软件包。RPM全称为“Red Hat Package Manager”,是一种在Red Hat及其衍生系统中使用的软件包格式,用于安装、卸载和管理...
本次分析的文件为一个名为 "redhat-lsb-submod-multimedia-4.1-27.el7.centos.1.x64-86.rpm.tar.gz" 的压缩包。从文件名可以推断,该压缩包包含的内容主要与 Red Hat Linux 发行版的 LSB(Linux Standard Base)...
Nero_Multimedia_Suite_10_Lite,一款小巧的刻录软件
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 ...
Learning Swift: Building Apps for macOS, iOS, and Beyond, 2 edition by Paris Buttfield-Addison and Jon Manning English | 2017 | ISBN: 1491967064 | 516 pages | PDF + EPUB | 24,7 + 22,5 MB Get valuable...