How to immediately stop a lottie animation if button is clicked in xamarin

Solution 1:

If you want to make your Animation go back immediately to the very first state of the animation, you can do this:

Animation.PlayFrameSegment(0, 0);

This will play the very first Frame of your animation, after that, you can restart the animation like you would normally do.

Solution 2:

Since Xamarin Lottie 4.0, the PlayFrameSegment method does not exist anymore. Instead you will have to use either:

Animation.PlayMinAndMaxFrame(0.0f, 0.0f);

or

Animation.PlayMinAndMaxProgress(0.0f, 0.0f);