I am working on an Android multimedia video processing application and am having a problem. I use the FragmentPagerAdapter class with several different fragments inside for the various stages of video processing.
My first Fragment contains SurfaceView and MediaPlayer , which serve it along with various playback controls. My problem arises when I scroll to fragment 1 (with SurfaceView) to fragment 2 (currently empty). If I have not called start() yet, nothing unusual happens and I can navigate normally between fragments. However, when I call start() , the whole screen starts blinking and SurfaceView on when I scroll through the next Fragment , even if I put the MediaPlayer on standby and did not SurfaceView frames to the SurfaceView . The only thing that stops this is to destroy the surface together with the displayed view by moving it to the third Fragment so that the FragmentPagerAdapter destroys the Fragment alone or exits the application through the home or back button so that the view is destroyed.
I canโt understand in my life why this happens, except that the SurfaceView rendering stream somehow interferes with the main UI thread. Nothing unusual appears on LogCat, so I'm a bit stuck. I am using Galaxy Nexus with android 4.1 as test equipment.
Any help would be appreciated!
Jt
UPDATE:. At the moment, I managed to find a workaround by overriding the setPrimaryItem() method in the FragmentPagerAdapter to call a method that removes SurfaceView from the hierarchy (using removeView() in the LinearLayout container) when the Fragment video player stops displaying and then restores SurfaceView again when it active again. When all this happens, unfortunately, it's still a little bit, therefore, if someone has additional thoughts, I would be grateful!
Psiloc
source share