1
votes

I need to display the camera preview in my ionic app. I tried the CanvasCamera cordova plugin but on Android it doesn't work. An issue was logged on the project's github project here https://github.com/donaldp24/CanvasCameraPlugin/issues/17 Unfortunately the developer is no longer maintaining that project.

Does anybody have an alternative method to preview the phone camera in ionic?

1

1 Answers

2
votes

I know 2 ways to get a high quality (1080p) camera frame preview with fast framerates (>30fps)

  1. WebRTC getUserMedia. But this works only on android >=5 aka Lolliop. iOS Safari does not support this right know. See http://caniuse.com/#feat=stream
  2. Stream the camera frame to a native view on iOS and Android and put this view behind the cordova webview. The cordova webview must have a native transparent background color and the DOM of the webcontent must als have transparent div's all the way up to . So you can "see through" the webcontent on the native camera preview view. You have to handle the sizing and device orientation via the cordova plugin api.

Number 2 is a bit more work but has a better native feeling. If you need to capture a frame (still image) you can capture it on the native side and then put it into javascript via plugin bridge.