Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run alpha animation on Video View android

I've successfully added VideoView on my layout and I'm able to play it too. I have a nice animating logo on top of videoview, when certain button is clicked. In the same time I want to fade out the video. But running alpha animation on it immedietly turn it black. I found that videoview is not behaving like an ordinary view, because it's surface view. I tried putting it inside frame layout, but it didn't work. Animation looks like this:

AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
alphaAnimation.setDuration(1000);
alphaAnimation.setFillAfter(true);

videoView.suspend(); //pause video
videoView.startAnimation(alphaAnimation);

So how can I fade out video?

like image 554
Makalele Avatar asked Jan 21 '26 15:01

Makalele


2 Answers

You cannot animate VideoView. Why don't you try using TextureView, which behaves just like a normal View. You can find how to play video in TextureView from this answer in SO.

like image 79
JiTHiN Avatar answered Jan 23 '26 03:01

JiTHiN


You can make Fade Out on VideoView:

final int duration = 400;
final int colorFrom = Color.parseColor("#10000000");
final int colorTo = Color.parseColor("#000000");
ColorDrawable[] color = {new ColorDrawable(colorFrom), new ColorDrawable(colorTo)};
TransitionDrawable transition = new TransitionDrawable(color);
videoview.setBackground(transition);
transition.startTransition(duration);
like image 23
maatik5 Avatar answered Jan 23 '26 04:01

maatik5



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!