0

I have a dialog where I put a surface that is used for a MediaCodec instance to play a video.

When I load this dialog, the surface appears transparent for a few seconds until the mediacodec is ready and the video plays fine. Since this is a dialog, the surface being transparent shows the activity below instead of, say, a black background.

Since I cannot hold the canvas to paint it black myself because that would block mediacodec from accessing it, how can I fix this?

MichelReap
  • 5,630
  • 11
  • 37
  • 99

1 Answers1

0

Can't you just define a black colored background in the dialog parent Layout ?

This way even if the surface is transparent the dialog below won't be

EDIT 1 :

This can make a surface view transparent, maybe try to play with it :

SurfaceView sfvTrack = (SurfaceView)findViewById(R.id.sfvTrack);
sfvTrack.setZOrderOnTop(true);    // necessary
SurfaceHolder sfhTrackHolder = sfvTrack.getHolder();
sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);

From this post : how to make surfaceview transparent

Community
  • 1
  • 1
An-droid
  • 6,433
  • 9
  • 48
  • 93
  • I do have a background, but even so for some reason when the video is loading I see the activity below – MichelReap Jul 05 '16 at 13:33
  • Could you post your full layout xml please ? – An-droid Jul 05 '16 at 13:33
  • I've read a bit and apparently a Surface is put on bottom of the current component, so this being a dialog no matter what background I put there, I will always have my surface beneath it :( – MichelReap Jul 06 '16 at 07:47