TextureView and Transparency - android

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.

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.

When playing video with surfaceview,the problem has happened

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.

Activity Background transparency and blur

I am trying to achieve a transparent background with a blurry effect on it. I managed to made the activity transparent but no luck with the blur. Could you help me to figure this out? I attached an image with contains what I would like to achieve(that blurry background below settings app).Thank you.Example
You can use Blurry library to achieve blur effect. It works perfect, but has minor bugs with activity state recreation (please check out issues)

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.

Hide video but have it continue to play

I have an image and a video player. In portrait, it shows both. Doing landscape left, just the video shows. Doing landscape right just the image shows.
I am using the setVisibility() method right now to achieve that. The problem with doing:
myVideoView.setVisibility(View.INVISIBLE);
causes the video to stop playing. Is there a way to keep it playing but also not visible to the user? Maybe like set the opacity of the VideoView to 0?
I think I found a solution here. In order to make videoview invisible and keep it playing sound you simply hide it by setting alpha value.
mVideoView.setAlpha(0f);
Hope it works for you!
You could try changing the z-order of the views with the bringToFront() method.
If you want the video to show then call mVideoView.bringToFront() and when you want the image to show you could use mImageView.bringToFront() this should work as long as the video and the image both occupy the same space on the screen.
Good luck

Categories

Resources