? To create a surfaceview inheritance class, you generally need to implement the following methods:
(1) surfacecreated (surfaceholderholder): called when this class is created. Initialization is generally required here, And surfacehodler is used to set the surface size and position;
(2) surfacechanged (surfaceholderholder, int format, int width, int height) is called when the surface size is changed. drawing is implemented here;
(3) surfacedestroyed (surfaceholderholder) is called when the surfa
Based on the videoview prototype, we can see that if you build a more complex and distinctive Video View,Surfaceview must be inherited and mediaplayercontrol interfaces must be implemented.. Surfaceview supports display and mediaplayercontrol supports media control.
Core playback class:
import android.app.Activity;import android.os.Bundle;import android.os.Environment;import android.util.Log;import android.view.SurfaceHolder;import android.view.SurfaceView;public class PlayerActivity extends Ac
decided to Google Baidu, but I couldn't find any solution after looking for a long time. This error gave me two days to get stuck, it makes me feel cold and cool ......
At the beginning, the encoder I designed only needs to pass a surfaceview object and use this object to preview the recorded video. The Code is as follows:
Public class hsf-encoder implements surfaceholder. callback {surfaceholder holder;
How does Android clear the canvas?
It seems that no good solution has been found. Some methods restrict the use of solid background, but no matter how you try it, there is no effect,
Finally found the answer on the http://stackoverflow.com/questions/4650755/clearing-canvas-with-canvas-drawcolor:
The result is as follows:
The effects of earlier unsatisfactory Images
(Note: The graph is directed to the top layer)
This class is as follows:
Package COM. test. move; import android. content
. view. surfaceholder; import android. view. surfaceholder. callback; import android. view. surfaceview; public class testview extends surfaceview implements callback, runnable {public static final int game_heart = 1000/30; // refresh 30 times per second public static int screenw, screenh; private thread; private surfaceholder holder; private paint; Public testvi
running. This requires a separate thread to repeatedly repaint the state of the person, to avoid blocking the main UI thread. Obviously, the view is not suitable and needs surfaceview for control.
Below is a basic framework using sufaceview:
Import Android. App. activity; Import Android. content. context; Import Android. Graphics. Canvas; Import Android. Graphics. color; Import Android. Graphics. paint; Import Android. OS. Bundle; Import Android. View. s
When using surfaceview, you will find that the ondraw (canvas) method of the parent class is not executed. The reason is that in surfaceview, we do not directly deal with it, but control it through surfaceholder. Use the lockcanvas () function of surfaceholder to obtain the canvas object of surfaceview, and modify the data in surfaceview by drawing the content on the canvas.
Public class mysurfaceview ex
After several errors, I modified a simple camera.ProgramFinished, photographyCodeAs follows:
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> 1 Class Surface Extends Surfaceview Implements Surfaceholder. Callback { 2 3 Surfaceholder sfholder; 4 5 Camera camera; 6 7 Bitmap bitmap; 8 9 Public Surface (con
Note: we have been developing games on the j2's platform for a long time. I want to switch to android this time. I think it's okay to think about it. So I wrote this article.
Let's talk about the source code.
Package Sur. Face. Pro;
Import android. content. Context;
Import android. graphics. Canvas;
Import android. graphics. Color;
Import android. graphics. Paint;
Import android. util. AttributeSet;
Import android. view. SurfaceHolder;
Import and
In fact, the previous article on surfaceview analysis is a simple game framework. Of course, I would like to emphasize that it is a simple game framework, so do not let the experts not spray it out ~
This Demo is a demo of image operations and button processing and a simple game framework for a group of kids shoes. We will share it with you here ~
Package com. himi;
Import android. content. Context;
Import android. content. res. Resources;
Import android. graphics. Bitmap;
Import android. grap
Most of the Code is the same as that of a music player.Put the video file in the sdcard and enter the file name in the input box.Use android2.0 to run the simulator. It is said that the simulator of other versions is used.Video Playback is not supported. If any error occurs, please noteThe java code is as follows:Package cn. mrzhu;Import java. io. File;Import android. app. Activity;Import android. media. MediaPlayer;Import android. media. MediaPlayer. OnPreparedListener;Import android. OS. Bundl
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.