https://kotlinlang.org logo
#compose
Title
# compose
o

Omkar Amberkar

10/24/2023, 5:17 PM
is there a recommended way to use
*AndroidExternalSurface*
for media playback? if so, how should it be set up? what should be the z order for it?
r

romainguy

10/24/2023, 5:21 PM
You don't need to change the Z order unless you have a good reason to do so
If you've used SurfaceView before, it's basically the same thing (it uses a SurfaceView underneath)
o

Omkar Amberkar

10/24/2023, 5:28 PM
yep, • z-ordering: the default z-ordering is behind, so was wondering if that needs to be updated • isOpaque: do we need to tweak this value? or just let it be true?OnAttachStateChangeListener in this case?
• also we need access to
View.OnAttachStateChangeListener
from the SurfaceView, is this a similar api recommended to use for compose?
r

romainguy

10/24/2023, 5:32 PM
Keep z-ordering and isOpaque to their defaults unless you know you need them
Why do you need the attach state?
AndroidExternalSurface
will invoke various callbacks already to help you. And if you need more you can always use Compose’s
DisposableEffect
o

Omkar Amberkar

10/24/2023, 5:35 PM
Attach tells the player the SurfaceView to render video into. Detach tells player to release the SurfaceView so that it won't be leaked
r

romainguy

10/24/2023, 5:37 PM
You can do this when you get the
onSurface
and
onSurfaceDestroyed
events in
AndroidExternalSurface
o

Omkar Amberkar

10/24/2023, 5:37 PM
cool, thanks 🙂
5 Views