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?
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With