animated gif - FLAnimatedImage multiple gif playback delay when using loop count - objective c -
i have uipageviewcontroller displays 5 gifs, 1 in each page. flanimatedimage works great, there 1 drawback, there nothing set animation loop , used https://github.com/flipboard/flanimatedimage/pull/60 achieve that.
but problem occurred after gif completes , stops in 1 controller , move controller , return previous controller, gif start after delay.
i'm not sure how fix that. delays in class flanimatedimages related animation delays , not playback delays.
here extract class flanimatedimage.m in method initwithanimatedgifdata
:
// try use unclamped delay time; fall normal delay time. nsnumber *delaytime = [framepropertiesgif objectforkey:(id)kcgimagepropertygifunclampeddelaytime]; if (!delaytime) { delaytime = [framepropertiesgif objectforkey:(id)kcgimagepropertygifdelaytime]; } // if don't delay time properties, fall `kdelaytimeintervaldefault` or carry on preceding frame's value. const nstimeinterval kdelaytimeintervaldefault = 0.1; if (!delaytime) { if (i == 0) { flloginfo(@"falling default delay time first frame %@ because none found in gif properties %@", frameimage, frameproperties); delaytime = @(kdelaytimeintervaldefault); } else { flloginfo(@"falling preceding delay time frame %zu %@ because none found in gif properties %@", i, frameimage, frameproperties); delaytime = delaytimesmutable[i - 1]; } } // support frame delays low `kdelaytimeintervalminimum`, below being rounded `kdelaytimeintervaldefault` legacy compatibility. // how fastest browsers per 2012: http://nullsleep.tumblr.com/post/16524517190/animated-gif-minimum-frame-delay-browser-compatibility const nstimeinterval kdelaytimeintervalminimum = 0.02; // support minimum when rounding errors occur, use epsilon when comparing. downcast float because that's delaytime imageio. if ([delaytime floatvalue] < ((float)kdelaytimeintervalminimum - flt_epsilon)) { flloginfo(@"rounding frame %zu's `delaytime` %f default %f (minimum supported: %f).", i, [delaytime floatvalue], kdelaytimeintervaldefault, kdelaytimeintervalminimum); delaytime = @(kdelaytimeintervaldefault); } delaytimesmutable[i] = delaytime; } else { flloginfo(@"dropping frame %zu because valid `cgimageref` %@ did result in `nil`-`uiimage`.", i, frameimageref); } cfrelease(frameimageref); } else { flloginfo(@"dropping frame %zu because failed `cgimagesourcecreateimageatindex` image source %@", i, _imagesource); } } _delaytimes = [delaytimesmutable copy]; _framecount = [_delaytimes count];
the solution workaround change uipagecontroller transition style curl instead of scroll, new instance of page content controller created , gifs reloaded memory.
Comments
Post a Comment