13

I have been playing with TextureView on some Android 4.0 devices. For example, I tried to develop a simple app, which can record the video and uses TextureView for its preview. However, as far as I read the Android API documents, standard MediaRecorder requires certain surface in order to perform video recording, but on the other hand, TextureView does not have its own surface anymore, so an incompatibility between TextureView and MediaRecorder seems exist.

MediaRecorder.setPreviewDisplay

TextureView

Does anyone know how to record video using standard MediaRecorder with TextureView as its camera preview? Or is there any way to record video other than MediaRecorder?

Thank you very much.

mylovepenguins
  • 131
  • 1
  • 4

1 Answers1

8

According to this issue, on Jelly Bean and higher, you simply don't call setPreviewDisplay(), and MediaRecorder will automatically use the preview used by the Camera. I can confirm that not calling setPreviewDisplay() does indeed work, at least on Android 4.2, when the Camera preview is set to be a TextureView. I have not yet tried this on older Android versions to confirm that 4.1 works.

This does leave a bit of a gap, in that Android 3.0-4.0 devices perhaps cannot use TextureView for previews.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • i am having the same problem, my htc one x with android 4.0 freezes the screen when using textureview as preview while trying to record a video with mediarecorder – xiaowoo Nov 13 '13 at 21:51
  • This completely saved my afternoon. I wouldn't been freaking out about this one otherwise. Seems to work on the S3, now going to try on 3 or 4 other devices. – Kevin Galligan Nov 22 '13 at 18:57