When is a GIF Finished Playing?

Scott Rossi scott at tactilemedia.com
Wed Feb 10 17:00:52 EST 2016


Nope, you just have to "know"  :-)

-HH makes a good point that I forgot about: if you control the playback
yourself, setting the GIF's currentFrame every so many millisecs, you'll
always know which frame you're on in the GIF.  This will work for most
GIFs, but can mess up playback of GIFs that use varying frame delays since
timing will differ from how the GIF was originally authored.

Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design




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

>Hi Scott - In my case I let my users decide how many times the GIF
>cycles, so it more than likely will be more than once through, but not
>infinitely as in -1.  I like your second option, below, but how are you
>getting the GIF's frame delay?  Did I miss that Livecode property
>somewhere?
>
>On 2/10/2016 4:06 PM, Scott Rossi 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:
>>
>> # 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