When is a GIF Finished Playing?

Scott Rossi scott at tactilemedia.com
Wed Feb 10 16:06:32 EST 2016


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:

# GIF WITH 10 MS FRAME DELAY

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


Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design



On 2/10/16, 12:06 PM, "use-livecode on behalf of Ray"
<use-livecode-bounces at lists.runrev.com on behalf of ray at linkit.com> wrote:

> It would also be helpful if a message was sent each time a new frame is
> displayed.  We could trap for those messages, count them, and go from there.
> 
> On 2/10/2016 2:48 PM, Sannyasin Brahmanathaswami wrote:
>>    
>>  I have a similar need.
>> 
>>  Seems we can set the repeatCount, but I don¹t see a way to test for
>> ³currentLoop²
>> 
>>  Theoretically we need something like ‹ where I am making up an unknown prop
>> called ³currentLoop":
>> 
>>  if (the currentFrame of img "myGif" = the frameCount of img ³myGif²) AND \
>>  (the currentLoop of img ³myGif" = the repeatCount of img ³myGif")
>> 
>>  then
>> 
>>  answer ³Ok I am indeed done²
>> 
>>  end if
>> 
>>  On February 10, 2016 at 9:29:57 AM, Ray
>> (ray at linkit.com(mailto:ray at linkit.com)) wrote:
>> 
>>>  Thanks Scott, but if you've set the RepeatCount to more than 1 and it's
>>>  looping through the frames, twice for example, isn't there a possibility
>>>  you'll get the CurrentFrame the same as the FrameCount too early?
>> 





More information about the use-livecode mailing list