I'm working with a VideoView for showing a video stream. Because I need the MediaController to be attached to the view itself and I want to prevent the black screen flicker caused by the videoview. I've tested the below code on my Nexus 7, worked like a charm. But now I tested it on my SGS2, and for some reason OnVideoSizeChanged is never called.
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
Log.i("ONPREP", "called");
mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() {
@Override
public void onVideoSizeChanged(MediaPlayer mp, int width, int height) {
videoview.setMediaController(mc);
mc.setAnchorView(videoview);
videoview.setBackgroundColor(Color.TRANSPARENT);
Log.i("ONSIZECHANGE", "called");
}
});
}
The video is playing like it should, I tested this by removing the OnVideoSizeChangedListener and just putting the code in the onPrepared method, but this is bringing back the screen flicker issue and leaves the mediacontroller unattached. This behaviour is also shown by the Log info in LogCat, ONPREP tag shows but never the ONSIZECHANGE. On my N7 both show, obviously cause the background color is changed.
This is the code that sets and starts the video:
videoview.setOnPreparedListener(MainActivity.this);
mc = new MediaController(MainActivity.this);
mc.setMediaPlayer(videoview);
videoview.setVideoURI(videourI);
videoview.start();
So why is it called on one device and not on another?
Edit: Tested it on my Note 2, same issue as on the SGS2.