2

I'm trying to do camera recording and drawings on top on Google Glass, using a LiveCard.

in a regular activity, this would be achieved by using a FrameLayout, with a SurfaceView for the camera preview 'in the back', and another View in front of it used for drawing.

but using a LiveCard, if one needs subsecond updates, one has to use the LiveCard itself as a Surface. according to the documentation: https://developers.google.com/glass/develop/gdk/reference/com/google/android/glass/timeline/LiveCard

If your application requires more frequent updates (several times per second) or rendering more elaborate graphics than the standard widgets support, enable direct rendering and add a SurfaceHolder.Callback to the card's surface.

 LiveCard liveCard; // initialized elsewhere
 liveCard.setDirectRenderingEnabled(true);
 liveCard.getSurfaceHolder().addCallback(callback);   You can then draw directly on the surface inside a background thread or in response

to external events (for example, sensor or location updates). Use the surfaceCreated and surfaceDestroyed methods to start and stop your rendering logic when the card is displayed or hidden.

now I can either draw my on stuff on this Surface, or I can give this to the MediaRecorder as the camera preview service, but can't do both, as it will fail with an error

I wonder if anyone has ideas on how to make this work still?

the way I'd draw into the LiveCard myself is to 'manually' lock the canvas, and call FrameLayout.draw(canvas); one option would be to have a layout that contains two SurfaceViews - one for the camera preview, and one for my own drawings, and use the same approach. but, even if I define such a layout in XML, I can't get the SurfaceViews created (e.g. the appropriate SurfaceView callbacks are never called, and any attempt of drawing on them results in failure)

Ákos Maróy
  • 919
  • 2
  • 10
  • 19

0 Answers0