How to pause/resume webp animation?
rantianhua opened this issue · comments
Is your feature request related to a problem?
The following example shown us how to play an animation webp:
FrescoWebImage(
controllerBuilder = {
Fresco.newDraweeControllerBuilder()
.setUri(poster.gif) // GIF or Webp image url.
.setAutoPlayAnimations(true)
},
modifier = Modifier
.fillMaxWidth()
.height(300.dp)
)
Now I want to control the animation to pause/resume or start/stop the animation. I can make the parameter of setAutoPlayAnimations to be a remember
field, however, FrescoWebImage will dismiss and show again, which is not smooth.
Describe the solution you'd like:
Provide a parameter to pause/resume the animation.
Hey @rantianhua, I believe you can pause and restart the animatable by adding this to your builder:
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
override fun onFinalImageSet(id: String?, imageInfo: ImageInfo?, animatable: Animatable?) {
animatable?.stop()
animatable?.start()
}
}
@rantianhua Happy to hear that!