When playing video with surfaceview,the problem has happened - android

I did not use PlatformView when playing videos on Android 4.4, as shown in the following code.
ViewGroup parent = ((ViewGroup) mRegistrar.view().getParent());
parent.addView(surfaceView);
I want to draw some widgets developed with dart on the playback area. If the surfaceview is below the flutterview, the surfaceview cannot be displayed.
As shown in the following code, if you are above the flutterview, the widget on the playback area cannot be displayed. Is there any good solution?
surfaceView.setZOrderMediaOverlay(true);
surfaceView.setZOrderOnTop(true);
parent.bringChildToFront(surfaceView);

You can use TextureView instead of SurfaceView.

I have solved this problem. If you use dart to draw widgets on SurfaceView, not only those widgets need to be transparent, but also FlutterView needs to be transparent so that the content of Surfaceview can be displayed. FlutterView needs to call enableTransparentBackground.

Related

Using SurfaceView without displaying it

I would like to draw on a SurfaceView but not display it. It's used to generate images that eventually get fed into codec to produce a video. According to the documentation, SurfaceView appears to be something that is intended to be displayed. Is it possible to use it without actually displaying it?
There is a setVisibility Method, maybe you try using that.
setVisibility(int visibility)
Set the visibility state of this view.

TextureView and Transparency

I have a TextureView with a mediaPlayer attached to it, so i can use its surface to display a video, so far it's working well.
Now i try to create a fade in animation for displaying the video and i have no clue of how to do it.
I tried with the setOpaque(false) setting and playing with the alpha setting but it doesn't have any effects.
Also i tried the textureView without a mediaPlayer and i notice that i can't change the background color either, it's always black.
The documentation say that the behaviour of this view is the same as the standard view, but it doesn't seem to be the case.
Does anyone know how to change the transparency of this view ?
Thanks
I also had this problem, and you just need to set setAlpha(0.999f) and it will have transparent background.

android setAlpha of video which playing in SurfaceView

currently I want to make effect like Youtube app on Android.
I want setAlpha of SurfaceView when the video has been minimized and is swiping left/right, just like Youtube App did.
but I found when I setAlpha of the RelativeLayout outside the SurfaceView, the whole Video disappear but the Layout is still visiable!
Also I found a same question
Android VideoView.setAlpha is not working (Xoom with 3.0)
can someone help me please?
thx!

android app with opengl navigation element, background image and video

i have done a view apps with setContetnView and the xml layouts... Actually I do some steps in opengl. Now i want to have one background image, a video area an the opengl 3d navigation element beside the video area to control the videos.
Is it necessary to do the whole work in opengl, or is it possible to put the opengl part over an existing view?
Where can I find more infos on this?
You can place the OpenGL view over top of the other views. I worked on an app that placed a OpenGLView over top of a VideoView. There may be some performance issues, so I would recommend adding the hardware acceleration attribute to your AndroidManifest.xml (under the application element):
android:hardwareAcceleration="true"
One thing that you will need to know to get the layout you expect is that the SurfaceViews do not conform to the normal view hierarchy, so you will want to set the z-order of the view programmatically, using the method setZOrderOnTop:
mVideoView.setZOrderOnTop(false);
mOpenGLView.setZOrderOnTop(true);

SurfaceView transparency problem

I have this problem: i added two view instances in a framelayout. First view is a VideoView which plays in loop a video. Second view is placed above the videoview and is a surfaceview. The surfaceview draws some .png's an a white rectangle which needs a small part of the screen. The part that is not needed must be transparent. in order to do that i used the next code lines (surfaceview implemnts SurfaceHolder.Callback):
setZOrderOnTop(true);
getHolder().setFormat(PixelFormat.Transparent);
The problem is that i want to make the white rectangle semitransparent in order to see the movie played by the videoview. The transparency effect works fine on the non used part of the surfaceview but the rectangle does not became semitransparent(if a i draw a background to surfaceview the effect becomes visible.) I wait a solution from u guys.Thx
Maybe the SurfaceHolder doesn't allow alpha. Have you checked the result of PixelFormat.formatHasAlpha()? Or have you tried explicitly setting PixelFormat.RGBA_4444, RGBA_5551 or RGBA_8888 to see what happens?
mVideoView.setZOrderOnTop( true );
getHolder().setFormat( PixelFormat.RGBA_8888 );
Worked for me.

Categories

Resources