Control play of GIF

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
FrankR
Posts: 28
Joined: Mon Apr 10, 2006 2:10 pm

Control play of GIF

Post by FrankR »

How do I

- Play the animation of a GIF just once and stop
- Repeat the play programmatically?

Thank you.
sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Control play of GIF

Post by sturgis »

look in the dictionary at repeatcount, framecount and current frame.

repeatcount says how many times the gif should loop the animation (natively, so to have it play once set the repeatcount to 1)

framecount returns the number of frames that the gif contains.

currentframe is of course the currently showing frame.

So, if you set the repeatcount to 1 the gif will stop animating after the first time through. Then if you want to animate it yourself 1 time through the animation something like the following should work.

repeat with i = 1 to the framecount of image "imagename"
set the currentframe of image 1 to i
wait 100 milliseconds with messages -- adjust this number as needed to get the frame flip speed desired
end repeat
FrankR
Posts: 28
Joined: Mon Apr 10, 2006 2:10 pm

Re: Control play of GIF

Post by FrankR »

That's extremely helpful. Thank you. I will go experiment.

Isn't there a way, though, to repeat the whole animation without a loop.

I could see needing the loop to play a segment of a GIF. But to just replay the whole GIF, there isn't
a way to do that without controlling the animation with a loop?
sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Control play of GIF

Post by sturgis »

Every time you set the repeatcount of the image it will play that many times.

So if the image is stopped and you then set the repeatcount of image "imagename" to 1, the animation will play 1 time.
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: Control play of GIF

Post by William Jamieson »

2 years later stumbled upon this post...

the answer is to set the repeat count to a negative number and it will play indefinitely
Post Reply