In my app, I'm displaying local videos using a SurfaceView. However, I noticed a strange (rare) bug when switching between videos: they both overlap.
Screenshot:
Sometimes the old video (top black video) stays still and sometimes it still continues playing. (with no audio)
How do I fix this? I was previously using a VideoView and still had this issue. My VideoFragment is recreated everytime I open a new video. I tried releasing the video in the onPause() of the fragment but still no luck.
@Override
public void onPause()
{
super.onPause();
if (player != null && Video.getDownloaded())
{
if(player.isPlaying())
player.stop();
controller.hide();
player.release();
}
}
Thanks in Advance,
~Pkmmte Xeleon
Simply put, a SurfaceView
is a weird "widget". Treat them carefully.
Try reorganizing your UI to have a single SurfaceView
(or VideoView
if you roll back to that). For example, that could be fixed below your action bar tabs, with the rest of your content inside a fragment beneath it. On a tab change, update the video and replace the main fragment.
Or, if you are only supporting API Level 14+, try TextureView
instead.