Start a new topic

HtmlDrawable with Animated GIF not playing consistently

HtmlDrawable with Animated GIF not playing consistently

I have an HtmlDrawable page with an animated GIF in it. Sometimes the GIF plays, other times it plays from the middle, but most of the time, it just shows the last frame (looks like it's not animated).

I know that the GIF can work because it seems to work sporadically- usually after I restart the app.

Is there some way to get the GIF to work consistently in the HTML embed?

The page also has a transparent background and so do the GIF - in case that makes any difference.

We have not tested animated GIFs for HtmlDrawables. Our suggested way for an animated image like GIFs is AR.AnimatedImageDrawable. It allows you to set an sprite sheet image. A sprite sheet image includes all animation frames in a grid like layout and you define how big one frame is in pixels. With AnimatedImageDrawables you have the benefit of controlling the animation, e.g. setting different frames to animate and their playback speed. Please have a look at the "Image Recognition - Bonus Sparkles" example that inlcudes such an AnimatedImageDrawable. Another benefit of this is that it is more lightweight than a HTMLDrawable.

If you still want to use the HTMLDrawables for GIF playback: I suspect that the behavior you are seeing with HTMLDrawables, is because the animated GIF already starts playback while the HTML Drawable is prepared to be drawn. You might be able to get it working by adding the GIF via JavaScript in the body onLoad event.
Login or Signup to post a comment