1

Is it possible to take screen shot of the WeemoVideoInFrame ? I have tried the following code and it gives me this. I think I need to acquire a reference of the underlying Surface to be able to take screenshots but is there really no way of achieving this? Can some one recommend a workaround this?

    view.setDrawingCacheEnabled(true);
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);

Christophe
  • 55
  • 9
cyc115
  • 635
  • 2
  • 14
  • 27

1 Answers1

2

Unfortunately, the internal View used to render the video frames is a TextureView, and therefore you can't request the drawing cache (TextureView is HardwareAccelerated).
Moreover, the documentation specifies that:

public final void draw (Canvas canvas)

Subclasses of TextureView cannot do their own rendering with the Canvas object.

So, your draw() call will have no effect on the TextureView.

Maybe you could try to use the getBitmap() method on the internal TextureView but I can't guarantee you this will work.
At this time, there is no such feature on the Weemo SDK, but we're investigating to provide a more convenient way of capturing these frames.

Also, it would be interesting for us to better understand your use case. Maybe you could share a bit more on what you are trying to achieve. This could help us design anew SDK feature that will best fit your needs.

Edit: To get a reference to this TextureView, simply browse the view hierarchy. You could for example do this:

WeemoVideoInFrame videoFrame = getView().findViewById(R.id.video_frame);
findTextureView(videoFrame);

/* ... */

TextureView findTextureView(WeemoVideoInFrame frame) {
    for (int index = 0; index < frame.getChildCount(); index++) {
        View child = frame.getChildAt(index);
        if(child instanceof TextureView) {
            return (TextureView) child;
        }
    }
    return null;
}

But keep in mind that this behavior is not guaranteed.

Simon Marquis
  • 7,248
  • 1
  • 28
  • 43
  • Thanks for answering ! Can you explain more how to obtain a reference to the internal TextureView it seems to be `private`. I am working on an specialized video chat app between an Android phone and Google Glass. One of the essential step is being able to take screenshot of the video streamed from the Glass to make some edits and send it back to the glass. – cyc115 Aug 01 '14 at 13:59
  • Still no luck, the screenshots I grab are either black or white. Do you know if `MediaMetadataRetriever` would work ? – cyc115 Aug 01 '14 at 18:06
  • `MediaMetadataRetriever` can only be used with a file, so it won't work. – Simon Marquis Aug 02 '14 at 09:29