Handling two surfaceViews

2019-02-15 08:54发布

问题:

I have two surface Views 1> MediaRecorder display surfaceview. 2> MediaPlayer SurfaceView displaying the Media recorded by MediaRecorder.

I want to display both the views simultaneously on the screen z ordered.

The mediaPlayer will be palying in full screen and the MediaRecorderPreview shd appear in the top right corner with some smaller size.

I am able to do this using two surfaces but the issue is that the MediaRecorder Preview always goes to the background z order and gets hidden by the mediaplayer full screen display.

Is their any way to define the Z order of Surface View.

Or is their any other suzzestion i can do to make this work. Can i start both MediaRecorder and MediaPlayer in a single surface?

Pls suggest. Thanks!!

回答1:

I want to display both the views simultaneously on the screen z ordered.

AFAIK, that is not supported by Android. Android cannot composite multiple SurfaceViews. It can handle a regular View (e.g., Button) on top of a SurfaceView, but not two SurfaceViews Z ordered.

I recommend redesigning your application to have a single SurfaceView at a time.



回答2:

As of Android 2 (API level 5) having 2 surfaceviews is supported. You can set the zOrder of the 2 surface views using setZOrderMediaOverlay although apparently it breaks the intended semantics of SurfaceView.