When is a GIF Finished Playing?

-hh hh at livecode.org
Wed Feb 10 16:20:50 EST 2016

Scott R. wrote:
> If you want the GIF to stop playing when it reaches the last frame, why
> wouldn't you set the repeatCount to 1?
> If your GIF can play multiple times through (repeatCount = -1), then I
> believe the only way you can track its frames is to poll it, with a
> frequency that slightly exceeds its frame delay.  Try running a loop while
> the GIF is playing, maybe something like:
> on mouseUp
>    set the repeatCount of img "myGif" to -1
>    trackPlayback
> end mouseUp
> on trackPlayback
>    if the currentFrame of img "myGif" > (the frameCount of img "myGif" - 1)
> then
>       set the repeatCount of img "myGif" to 0
>       set the currentFrame of img "myGif" to the frameCount of img "myGif"
> -- just to be sure
>       exit trackPlayback
>    end if
>    send "trackPlayback" to me in 8 millisecs
> end trackPlayback

I'm currently working on a LC stack, that runs animated pictures (from screenShots) on Raspi, because GIF animation is sometimes unreliable there. LC is pretty good with that even if one does this by setting filenames of the frames. So I could compare for myself:

If you do such a polling as above then it is LESS effort for the CPU and you have moreover FULL control on the animation if you do it by yourself:

SPLIT the gif into it's frames as GIF, PNG or whatever (there are online-tools for that) and animate them by send "handler" <in time>.

You can then even play parts of the original GIF (adjust by that to differnet CPUs), zoom single frames and and ...

More information about the use-livecode mailing list