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

zt

06/24/2022, 2:11 AM
I'm using the exoplayer lib and a problem I have is that fading doesn't work, so it just pops in and out. Is there some way to fix this?
Copy code
@Composable
fun Player(
    modifier: Modifier = Modifier,
    player: Player,
) = DisposableEffect(
    AndroidView(
        modifier = Modifier
            .aspectRatio(16f / 9f)
            .then(modifier),
        factory = { context ->
            PlayerView(context).apply {
                this.player = player
                useController = false
                useArtwork = true
                resizeMode = AspectRatioFrameLayout.RESIZE_MODE_FIT
            }
        }
    )
) {
    onDispose(player::release)
}
Whats weird is if I add
videoSurfaceView!!.alpha = 0.9f
in the apply block then the fade transition works
g

Grégory Lureau

06/24/2022, 7:59 AM
Maybe an optimization that view is not loaded when alpha==0.0f ? Have you tried to fade in from 0.00001f ?
m

myanmarking

06/24/2022, 9:17 AM
i noticed this issue with maps as well. I don’t know if it is expected, but setting alpha on a map make it disappear. Maybe the same with video?
f

fengdai

06/24/2022, 1:31 PM
Have you tried setting
surface_type
to
texture_view
?
Copy code
app:surface_type="texture_view"
14 Views