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/
分享到:
相关推荐
官方离线安装包,亲测可用
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 ...
CSR-BlueCore5-Multimedia-External-CS-101568-DSP4(蓝牙多媒体芯片-csr-bc05-mm)原理图
官方离线安装包,亲测可用
官方离线安装包,亲测可用
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...
官方离线安装包,亲测可用
标题:“Signal-Processing-for-Image-Enhancement-and-Multimedia-Processing”表明了书籍的主题是信号处理技术在图像增强和多媒体处理领域的应用。信号处理是一个广泛而深入的领域,它包括数据的分析、处理、解释...
There are chapters dealing with all the important aspects of the Android platform, including GUI design, file- and data-handling, coping with phone calls, multimedia apps, interaction with location ...