This article is mainly about: using the camera API to capture video data and save to a file, using Surfaceview, Textureview to preview the Camera data, take the NV21 data callback.Note: Requires permission:First, preview the Camera dataPeople who have done Android development generally know that there are two ways to do this: Surfaceview, Textureview.Here's how to preview your data using Surfaceview: Surfaceview Surfaceview; Camera camera; @Override protected void onCreate (Bundle savedin
static final int down_zero=60;
When the ball hits the ground, the speed is less than the value of 0 bitmap[] Bitmaparray =new bitmap[6]; Bitmap Bmpback; Background picture Bitmap Bmpwood; Bezel picture String fps= "fps:n/a"; string int ballnumber = 8 to display the frame rate; Ball number arraylist
Because the pictures in the Bitmaparray array are of large size and small size, the small size picture will not be blocked in order to draw the picture, so use the large size picture first.
The
How to achieve the auto focus of the Android camera, and it is continuously autofocus. Of course the direct call to the system camera is needless to say, that is very simple. Let's take a look at how to implement a camera on your own and achieve automatic continuous focus.
The code is as follows:
public class Mainactivity extends activity {private Surfaceview Surfaceview;
Private Surfaceholder Surfaceholder
image, and these images quickly displayed in the interface, that is, to play a video. Surfaceview is doing this in Android. Surfaceview is used in conjunction with MediaPlayer, MediaPlayer also provides the appropriate method to set the Surfaceview display picture, only need to specify MediaPlayer display image for Surfaceview. Its full signature:void Setdisplay (Surfaceholder sh). It needs to pass a Surfacehol
Build a Camera Application
Some developers may want to customize the Camera user interface in their applications, or provide some special functions. Creating a custom Activity requires more code than using Intent, but it can provide a better user experience.
Follow these steps to create a customized Camera interface:
1. Check and access Camera: Create Code to check the existence of Camera and requested access;
2. Create a preview class: Inherit SurfaceView to create a Camera preview class and im
The previous introduction of the use of Videoview play video, using Videoview play video simple and convenient, but the habit of using MediaPlayer developers or use MediaPlayer; MediaPlayer itself is mainly used to play audio, not provide video output screen, need to rely on Surfaceview,videoview is its sub-class;To play a video step:"1" Layout file join Surfaceviewuses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>"3" Create MediaPlayer object, load video fileplayer.setDat
Use of SurfaceView in Android game development-android learning journey (5)SurfaceView and View
In the main ui thread, View directly responds to user operations and distributes tasks. However, complicated tasks may cause blocking.SurfaceView does not have this problem, so that it directly retrieves images from memory and so on. More importantly, SurfaceView can change the Ui through threads outside the main thread.Use
Ui updates are divided into active updates and passive updates. For passive up
); }}5. Preview view and take photosWe generally use SurfaceView the preview view as a camera, you can also use texture. Get Surfaceholder in Surfaceview and setPreviewDisplay() preview via interface settings. After setting the Preview view, Be sure to remember the following two points:
Invoke startPreview() the method to start the preview, otherwise the Preview view will not display anything;
The photo operation needs to be startPreview(
the main thread to modify the interface (child thread can not directly modify the interface).
Although this demo function is realized, but not the effect I want, because I can not pass this one, to the product side more needless to say. What about it?
So I thought of a control, called Surfaceview, do game development comrades, should this control is not unfamiliar? First, let's introduce this control:1.SurfaceView inherits from view and is used in game development2. Can be run directly in a c
(Surfaceholder.surface_ Type_push_buffers);
The fifth step is to add a callback method for Surficeview (CallBack)
Surfaceview.getholder (). Addcallback (New Surfacecallback ());
The callback class above is our own definition, and the code is as follows
Private class Surfacecallback implements surfaceholder.callback{@Override public void surfacecreated (Surfaceholder Holder) {try {camera = Camera.open ();//Turn on the hardwa
During this time, I always saw online video playback materials and summarized them as follows:
1. You don't have to say anything about playing a local video, whether it's videoview, surfaceview, or mediaplayer.
2. Online playback server video:
A. You can use videoview or surfaceview to play a video in progressive download format.
B. Streaming Media videos can also be used (this is the best and most popular. It's a pity that I have read some materials and I haven't done it yet ...)
The code for i
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.