GlSurfaceView setZMediaOrder causing video to play outside its parents

Viewed 136

Case-1:

GLSurfaceView
|
FrameLayout
|
TextureView
|
VideoRecording

So here I have a GLSurfaceView, based on user input I am adding a square FrameLayout on top of it (dimensions are set using layoutparams) and then adding TextureView on top of this newly added FrameLayout and then recording the video, As expected, irrespective of what camera choose, I get a square preview.

Case-2:

GLSurfaceView
|
FrameLayout
|
GLSurfaceView
|
VideoPlayback

In the case-1 after recording the video I am adding another GLSurfaceView by removing the previous TextureView from the already added FrameLayout. Earlier, I could just hear the sound of playback without any video, but later I came across examples which were using
setZOrderMediaOverlay(true);
or
setZOrderOnTop(true)
Now the video plays, but instead of playing within its parent, its playing in 9/16 aspect ratio. As mentioned earlier, Expected behavior is square video (Dimensions of the FrameLayout).

How can I get the newly added video on top of background video without getting it out of the bounds of its parents.

1 Answers
Related