surfaceview

Using the camera in Background Android

江枫思渺然 提交于 2019-12-19 10:11:37
问题 I'm trying to get the picture into service from Camera. @Override public void onCreate() { super.onCreate(); //android.os.Debug.waitForDebugger(); myCamera=Camera.open(); SurfaceView dummy=new SurfaceView(getApplicationContext()); try { if(myCamera!=null) { myCamera.setPreviewDisplay(dummy.getHolder()); myCamera.setPreviewCallback(this); Log.i(TAG,"myCamera is not null"); } getFrames(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG,

Using a custom SurfaceView and thread for Android game programming (example)

人盡茶涼 提交于 2019-12-19 04:25:20
问题 I am trying to use SurfaceView, but the lockCanvas(null) is confusing, and the app freezes when I exit the activity. Also, nothing is displayed, even though the tutorial I was using was working perfectly fine, and I don't understand what I am doing wrong. Please help. 回答1: The solution is probably that setWillNotDraw(false); was not called. Therefore, a referential implementation that works properly would be the following: public class GameSurfaceView extends SurfaceView implements

Resize/Scaling down a YouTubePlayerFragment while video is playing

北慕城南 提交于 2019-12-18 13:38:29
问题 I am trying to replicate the video minimization in the Youtube app as shown here. In order to achieve this, I've tried using the Draggable Panel library. When I ran the sample, I noticed that the video does not scale but rather crops when minimized during playback. When the video is stopped (not paused) and displaying a thumbnail, the view scales as its supposed to. I read on another question that YouTubePlayerView is implemented with a SurfaceView. I also read in the docs that SurfaceView

How to reconcile difference in aspect ratio between camera preview size and picture size

你说的曾经没有我的故事 提交于 2019-12-18 12:33:43
问题 I've got a camera app that selects a preview size based on characteristics of my layout (primarily aspect ratio) and then selects a picture size based on other constraints (minimum dimensions). This often results in a picture with a different aspect ratio than the preview. This is not a problem in itself, but I need to map a rectangle on my preview to an equivalent rectangle on the picture so that I can extract the same area of the final photo that was visible in the preview when the photo

Animation glitches while rendering on SurfaceView

旧城冷巷雨未停 提交于 2019-12-18 09:49:12
问题 The FPS is around 60, but the animation still glitches sometimes. I did threads profiling and discovered that on Samsung S4 or Samsung S3 lockCanvas() could take up to 20ms sometimes. Is there any specific reason for it? How to avoid such glitches. 回答1: Some devices, particularly those based around qcom CPUs, will aggressively manage power by lowering clocks, so you will see occasionally glitches in 60fps animation when your finger isn't actively moving across the touchscreen. The best way to

SurfaceView height + width gets ignored

淺唱寂寞╮ 提交于 2019-12-18 05:10:22
问题 The following script works flawless, but the size of my videoplayer will get f'd after changing my surfaceview from portrait to landscape. Tried several options like setFixedSize() , setSizeFromLayout() and removing everything which involves my width + height from my surfaceview. Does anyone knows whats wrong with the code below? Or did someone have the same problem in the past? package com.list; import io.vov.vitamio.MediaPlayer; import io.vov.vitamio.MediaPlayer.OnBufferingUpdateListener;

How to implement pinch-zoom feature for camera preview [closed]

懵懂的女人 提交于 2019-12-18 03:39:26
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . i tried pinch-zoom feature for image from this.it works fine but how can i implement pinch-zoom feature for camera preview. Please help me. Thanks in advance. 回答1: This is what I used to add pinch to zoom. The link to the code is here: https://github.com/maxtower

getSupportedPictureSize() returns a value which is not actually supported by Nexus4

…衆ロ難τιáo~ 提交于 2019-12-18 01:20:27
问题 I have extended a SurfaceView for displaying the camera feed for a very simple camera application. To find the optimal preview size for each device, I used this sample code which is used in almost all the open source camera apps I have seen: List<Camera.Size> sizes = parameters.getSupportedPreviewSizes(); double minDiff = Double.MAX_VALUE; for (Camera.Size size : sizes) { if (Math.abs(size.width - width) < minDiff) { screenWidth = size.width; screenHeight = size.height; minDiff = Math.abs

Fighting with SurfaceView, Camera and OpenGL

大兔子大兔子 提交于 2019-12-17 23:45:11
问题 We've been fighting with some problems relating to SurfaceViews for more than a week, and find no proper solution to them. We read the other questions in the forum regarding to similar problems (and even Mixare source code) but couldn't find an answer, so we hope you could help us somehow. Scenario: We've got a SurfaceView for the Camera a SurfaceView for an OpenGL layer, which goes on top of the camera. another View, which shows some information about what we can see on the screen. This one

How to attach MediaPlayer with SurfaceView in android?

只愿长相守 提交于 2019-12-17 22:24:48
问题 I'm building video player with android media player object. i'm able to hear the audio but the video does not appear on surfaceView. here is my code public class PlayerActivity extends Activity implements SurfaceHolder.Callback { String path; private MediaPlayer mp; private SurfaceView mPreview; private SurfaceHolder holder; boolean pausing = false; public static String filepath; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R