I have a VideoView which I want to use to play a movieclip. I use it like this to play it and it works.
VideoView vv = new VideoView(this);
vv.setVideoURI(Uri.parse("android.resource://cortex2.hcbj/raw/intro"));
setContentView(vv);
vv.start();
However I see a black flash just before and after the movie clip. The flash in itself isn't a big problem, but the blackness of it is. The background is white, so if the flash is white, or if it dissapears it will be okay.
Another solution that might work for people who are searching for this question:
In my case, the video was a resource in the app (that is, I knew everything about it and it wasn't going to change) and its last 500 ms were the same frame, so I ended up doing the following:
and the referenced class is:
Explanation: Immediately after starting the video I create a Runnable and postDelayed it to the root view (
android.R.id.content
) to the duration of the video, minus the length at which I'm willing to pause the video (and a generous buffer, because postDelayed isn't guaranteed to play exactly after the requested time)Then, the runnable checks if the video arrived at its pause-time, if so it pauses it and does whatever else we want it to do. If it doesn't, it runs postDelayed again with itself, for a shortened time (100 ms in my case, but could be shorter)
Granted, this is far from being an ideal solution, but it might help someone with a specific problem similar to the one that stumbled me for half a day :)
I know it's old question but if you can add some code to MediaPlayer listeners there is very simple answer. It turned out that setBackgroundColor for VideoView changes the foreground color ( https://groups.google.com/forum/?fromgroups=#!topic/android-developers/B8CEC64qYhQ ).
So the only thing you have to do is switching between setBackgroundColor(Color.WHITE) and setBackgroundColor(Color.TRANSPARENT).