Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid - MediaRecorder - Application lost the surface
    text
    copied!<p>I first try to create the SurfaceView with: </p> <pre><code>SurfaceView sv = new SurfaceView(context); // Get a surface surfaceHolder = sv.getHolder(); // tells Android that this surface will have its data constantly // replaced surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); wm.addView(sv, params); </code></pre> <p>Then try to prepare recorder:</p> <pre><code>try { camera.unlock(); mediaRecorder = new MediaRecorder(); mediaRecorder.setCamera(camera); mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); mediaRecorder.setProfile(CamcorderProfile .get(CamcorderProfile.QUALITY_HIGH)); mediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO, appName).toString()); mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface()); mediaRecorder.prepare(); } catch (IllegalStateException e) { releaseMediaRecorder(); Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage()); return false; } catch (IOException e) { releaseMediaRecorder(); Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage()); return false; } return true; </code></pre> <p>But I get an error "Application lost the surface" despite that I can see that preview is working. Why is that?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload