How do you get the duration of a GIF? #1264
-
Hey, I'm thinking of displaying a duration indicator at the bottom of the screen when displaying a GIF. However, I couldn't find any way to actually get this information from the Coil API. I understand that you're supposed to sum the delays of all frames, but how do you actually get the frame delays in the Coil context? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I don't think it's possible to get the GIF duration at the moment. To add this feature ImageDecoder would need to expose that info as well. |
Beta Was this translation helpful? Give feedback.
-
Using @colinrtwhite advice and the Metadata Extractor Library, I've implemented this feature. For those looking for the same thing, I've posted a full gist of the code: https://gist.github.com/natanfudge/709c6a86097da4162fa47074e632317b. Note it does use some reflection to access internal Coil classes, it would be nice if you could find an alternative! |
Beta Was this translation helpful? Give feedback.
Using @colinrtwhite advice and the Metadata Extractor Library, I've implemented this feature. For those looking for the same thing, I've posted a full gist of the code: https://gist.github.com/natanfudge/709c6a86097da4162fa47074e632317b.
Note it does use some reflection to access internal Coil classes, it would be nice if you could find an alternative!