Android SurfaceView shows image after video (transparent surface)

My task is to play the video on SurfaceView after you pause the image in SurfaceView

My code to play

mPlayer.setOnCompletionListener(onCompletionListener); mPlayer.setDisplay(view.getHolder()); mPlayer.reset(); mPlayer.setDataSource(file.getAbsolutePath()); mPlayer.prepare(); mPlayer.start(); 

everything is ok video playback

in onCompletion

 mPlayer.reset(); mPlayer.setDisplay(null); view.setBackgroundDrawable(Drawable.createFromPath(file.toString())); 

but the image is transparent, and in the background I see the last video frame - it is not there. How transparent is the surface?

I'm trying to use

 holder.lockCanvas() 

but it returns null, why?

+4
source share
1 answer

I have the same problem and I fixed it using these two lines after the release of the player.

 surfaceViewHolder.setFormat(PixelFormat.TRANSPARENT); surfaceViewHolder.setFormat(PixelFormat.OPAQUE); 
+1
source

Source: https://habr.com/ru/post/1498703/


All Articles