简体   繁体   English

不带相机的SurfaceView:开始旋转90度后预览

[英]SurfaceView without camera : preview after start rotated on 90 degree

my problem. 我的问题。 I create app which do preview from camera on android. 我创建了从Android上的相机预览的应用。 For preview while im not press on button - i used Camera , camera.open. 为了在不按按钮的情况下进行预览-我使用了Camera,camera.open。 When app started - the orientation of screen is normal.. But when i try to record video - i closed camera preview and used only SurfaceView with recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT); 当应用启动时-屏幕方向正常。.但是当我尝试录制视频时-我关闭了摄像头预览,仅使用了带有Recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT)的SurfaceView; It's showing me preview from camera without class Camera. 它向我显示了不带Camera类的相机预览。 All this i do becouse it's fixed for me bug with greenish screen after recorded. 我所做的所有这些都是因为它已为我修复了录制后屏幕呈绿色的错误。 So... this preview(which without camera) he after start always rotated on 90 degree ( Like in mode LANDSCAPE) im try to use 所以...此预览(不带摄像头)在他启动后始终会旋转90度(例如在LANDSCAPE模式下),因此我尝试使用

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );

and

setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );

but it not fixed my problem. 但这并不能解决我的问题。 So, can any one tell me how to rotate my preview(without camera) in mode like SCREEN_ORIENTATION_PORTRAIT ?? 因此,任何人都可以告诉我如何在SCREEN_ORIENTATION_PORTRAIT之类的模式下旋转预览(不带摄像头)吗?

pls tell me how to fix this problem.. i can't fix it 2-3 days :( 请告诉我如何解决这个问题..我不能解决2-3天:(

Regards, Peter ps sorry for my bad english, hope u understand me. 问候,彼得·ps为我的英语不好对不起,希望你能理解我。

it's code which i used for preview when i recorded video/audio 这是我录制视频/音频时用于预览的代码

 preview = new SurfaceView(withPreview.this);
 preview.getHolder();
 holder.addCallback(this);
 holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS );

get picture from camera 从相机获取图片

recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);

now the screen rotated on 90 degree. 现在屏幕旋转了90度。 if i set 如果我设置

recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

than image rotated on 180 degree О_О 比将图像旋转180度О_О

and set preview 并设置预览

recorder.setPreviewDisplay(holder.getSurface());

that's all what i need for camera preview How u can see im not using Camera.. so i can't us camera.parameters.setOrientation(90) //example :] 这就是我预览相机所需要的全部内容。如何才能不使用Camera看到即时消息..所以我不能使用camera.parameters.setOrientation(90)// example:]

is it right, that you will fix the Screen Orientation to Landscape or Portrait? 是的,您将屏幕方向固定为横向还是纵向? Or should it be dynamic? 还是应该是动态的? So if i understand you, to fix the orientation of the screen, then i prefer to add this into your Android Manifest: 因此,如果我了解您,要固定屏幕的方向,则希望将其添加到您的Android清单中:

android:screenOrientation="landscape"

This must inside the activity-block. 这必须在活动块内。

Hope this will help, otherwise tell me when it should dynmaic or so on. 希望这会有所帮助,否则请告诉我何时应该进行动态处理等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM