Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting background colour for VideoView hides the video

I am using a VideoView in my app and when I set the background colour with either the layout properties, or in the code itself, the background colour is laid over the top of my video and I cannot see it.

like image 721
Mr Pablo Avatar asked Mar 14 '14 10:03

Mr Pablo


1 Answers

VideoView extends SurfaceView, which relies on PorterDuff.Mode.CLEAR to cut a hole in the view hierarchy so that you can see a native rendering surface underneath. If you make it fill itself back in with a solid color, you will not be able to see the video. While the video is playing, you would not be able to see the background, so I assume you want it to be a different color while there is no video. In that case, use the OnCompletionListener of the MediaPlayer to change things... perhaps switch views or extend VideoView and override draw so that it calls the super class method while playing and does something different at other times.

like image 162
Dave Avatar answered Oct 24 '22 13:10

Dave