noties / Markwon

Android markdown library (no WebView)
https://noties.io/Markwon/
Apache License 2.0
2.76k stars 313 forks source link

Coil gifs #424

Closed DanielJ06 closed 1 year ago

DanielJ06 commented 1 year ago

Hey! I'm currently using coil as the image renderer, but I can't figure out how to render gifs. I tried this image loader following coil docs:

val coilLoader = ImageLoader.Builder(context)
        .apply {
            crossfade(true)
            components {
                if (SDK_INT >= 28) {
                    add(ImageDecoderDecoder.Factory())
                } else {
                    add(GifDecoder.Factory())
                }
            }
        }.build()
    //...
    .usePlugin(CoilImagesPlugin.create(context, coilLoader))
   //...

The gif renders but never starts

The gif is declared this way in my markdown: \n\n![Gif Aplicação](https://victor-harry.s3.sa-east-1.amazonaws.com/V%C3%ADdeo+do+WhatsApp+de+2023-01-23+%C3%A0(s)+22.47.05.gif)\n\n

I don't know if I have to do an extra step to work with Markwon, or if my gif is declared wrong, can someone help me? thx

wax911 commented 1 year ago

I thought of using .target() and providing a object : Target { } to check if the onSuccess(drawable: Drawable) instance was an AnimatedDrawable and triggering the .start() method for it since this is similar to how Glide would handle gifs in Markwon. Unfortunately this didn't work 😞

noties commented 1 year ago

Hello @wax911 ,

you would need to use Animatable interface to check if loaded drawable is a GIF. And call start if you wish for it to start playing