Question

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);

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top