Recent projects need to add a short video function, the function is set to resemble the micro-letter, click Start Shooting, set the longest shooting time, after the research finally realized this function, and then share with you, hope to help you.
1. Video Recording custom controls:
/** * Video Playback control/public class Movierecorderview extends LinearLayout implements Onerrorlistener {private Surfaceview M
Surfaceview;
Private Surfaceholder
, you can also
Use the Mediacontroller class, but implement the Mediacontroller.mediacontroller interface * To implement some control methods. * * Then, set Controller.setmediaplayer (), Setanchorview (), setenabled (), show () on it, this is no longer implemented * @author Administrator */public class Videosurfacedemo extends activity implements Oncompletionli Stener,onerrorlistener,oninfolistener, Onpreparedlistener, Onseekcompletelistener,onvideosizechangedlistener,
surfaceholder.c
This article briefly discusses the architecture of future Android game engine templates. In the Android game development Tutorial II: The View class and the Surfaceview class we've talked about, Surfaceview class has a lot of advantages, so in the Android game development or choose Surfaceview.
Here we inherit Surfaceview directly, implement Surfaceholder.callback interface, deal with surfacecreated, surfacechanged and Surfacedestroyed methods, Here we do not have the key to control the incomin
the time of receiving, need to first judge is not empty, otherwise prone to error, received, we can carry out data storage operations, but do not know why, this way in the simulator can not be implemented, it may be necessary hardware support it, because the program needs, so many times, A number of different SDK simulator test, has not been successful.
The call was later changed in this way:
Import Java.io.BufferedOutputStream;
Import Java.io.File;
Import Java.io.FileOutputStream;
Import
Mainactivity extends Appcompatactivity {private Surfaceview surfaceview; private Camera Camera; private But
ton take;
@Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Requestwindowfeature (Window.feature_no_title);
No headers must find the call Setcontentview (R.layout.activity_main) before setting the layout; /* GetWindow (). SetFlags (WindowManager.LayoutParams.FLAG_FULLSCREEN,//Set full screen display WindowManager.LayoutParams.FLAG_
fullscr
Hello everyone, this is a simple photo function, very simple interface, a display image area Surfaceview A "Take a picture" button. Directly on the code! 1, Camerademoactivity.java (main interface) PackageOrg.winplus.camera; ImportJava.io.File; ImportJava.io.FileOutputStream; Importjava.io.IOException; Importjava.util.Date; Importandroid.app.Activity; ImportAndroid.content.pm.ActivityInfo; ImportAndroid.graphics.PixelFormat; ImportAndroid.hardware.Camera; ImportAndroid.os.AsyncTask; ImportAndroi
Rssurfaceview directly inherits from Surfaceview, and implements the Surfaceholder.callback callback interface. The parsing is as follows:1. Construction Method 1Public Rssurfaceview (Context context) { super (context); Init (); LOG.V (Renderscript.log_tag, "Rssurfaceview"); }2. Construction Method 2 Public Rssurfaceview (context context, AttributeSet Attrs) { Super (context, attrs); Init (); LOG.V (Renderscript.log_tag, "Rssurfaceview"); }3. In
specifies the playback position (in milliseconds)
SetAudioStreamType: Set the streaming media type
SetDataSource
SetDisplay settings use SurfaceHolder to display multimedia
SetLooping
SetOnButteringUpdateListener network streaming media buffer listener
SetOnErrorListener
SetOnVideoSizeChangedListener video size monitoring
SetScreenOnWhilePlaying: Set whether to use SurfaceHolder to keep the screen displaye
"Create a preview class" section, add your startFaceDetection () method to the surfaceCreated () and surfaceChanged () Methods of your preview class, as shown in the following code:
[Java] public void surfaceCreated (SurfaceHolder holder ){Try {MCamera. setPreviewDisplay (holder );MCamera. startPreview ();StartFaceDetection (); // start face detection feature} Catch (IOException e ){Log. d (TAG, "Error setting camera preview:" + e. getMessage ());}}
) supports sensors.
* @ Explanation: This sensor not only detects the player's mobile phone reversal action, but also gets different sensor values based on the extent to which the mobile phone is reversed!
*/
Public class MySurfaceView extends SurfaceView implements Callback, Runnable {
Private Thread th = new Thread (this );
Private SurfaceHolder sfh;
Private Canvas canvas;
Private Paint paint;
Private SensorManager sm;
Private Sensor sensor;
Private
;Android.view.SurfaceHolder import;Android.view.SurfaceView import;+ Import Android.view.View;Import Android.widget.Button;Import Android.widget.Toast;20$ public class Mycameraactivity extends Activity22 {Surfaceview Msurfaceview = null;Private Surfaceholder msurfaceholder = null;Private Button Takepicturebutton = null;+ Private Camera Mcamera;27//records are saved in the first few pictures-private int whichpicture = 0;29/** called when the activity i
1. Surfaceview is the inheritance class for view, which has a built-in surface for drawing. You can control the format and size of this surface. Surfaceview controls where this surface is drawn. surface is a deep sort (z-ordered), which indicates that it is always behind its own window. The Surfaceview provides a visible area that is visible only on the surface portion of the visible area and not visible outside the visible area. The layout display of surface is affected by the view hierarchy, a
Reference: zero-based Android game programming Related knowledge points: 1, callback a surfaceview must implement a Surfaceholder.callback interface. To notify view when the underlying surface state changes, the interface needs to implement the following 3 methods: publicvoidsurfacecreated ( Surfaceholderholder) {}publicvoidsurfacechanged (SurfaceHolder Holder,intformat,intwidth,intheight) {}publicvoid surfacedestroyed (Surfaceholderholder) {}2,
retrieved data, because the camera defaults to the byte[of the horizontal screen] Rotateddata = new Byte[data.length]; for (int y = 0, y Cameraview:Package Com.song.zxing.ui;import Android.app.activity;import Android.content.context;import Android.hardware.camera;import Android.util.attributeset;import Android.view.surfaceholder;import Android.view.surfaceview;import Com.song.zxing.app;import Com.song.zxing.util.autofocusmanager;import java.util.list;/** * Use decrypted Api Mcamera */public
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.