My task - play video on SurfaceView, after stop show image in SurfaceView
My code for play
mPlayer.setOnCompletionListener(onCompletionListener);
mPlayer.setDisplay(view.getHolder());
mPlayer.reset();
mPlayer.setDataSource(file.getAbsolutePath());
mPlayer.prepare();
mPlayer.start();
all ok video playing
in onCompletion
mPlayer.reset();
mPlayer.setDisplay(null);
view.setBackgroundDrawable(Drawable.createFromPath(file.toString()));
but image is transparend and on background i see last video frame - its no good. How clear surface?
I try use
holder.lockCanvas()
but this return null, why?
I have a same problem and i fixed it by using these two lines after player release.
surfaceViewHolder.setFormat(PixelFormat.TRANSPARENT);
surfaceViewHolder.setFormat(PixelFormat.OPAQUE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With