Gif not playing after first time

Hi everyone,

I am having a GIF and I want it to play once whenever I show it. For example,

$w('#gif').src = "some gif";
$w('#gif').show();

setTimeout(() => {
    $w('#gif').hide('FadeOut');
}, 2000);

Some time later after the GIF is done playing and hidden, I would like to show the GIF again. So basically re-running the above code snippet.

HOWEVER, this time (second time code snippet is ran) the GIF is no longer playing. It is stuck at the last frame from previously. How do I solve this?

I would NOT like a looped GIF because I only want it to be played once, but the issue now is that it is no longer playing after being shown a second time.

Thanks!

$w.onReady(function () {
    reRun();

});

function reRun () {
    $w('#gif').src = "some gif";
    $w('#gif').show();

setTimeout(() => {
    $w('#gif').hide('FadeOut');
}, 2000);
reRun ();

 
}

Try This Method:
Write a function and call initially and Call Inside the Loop.

It Will Become Infinity Loop

This would result in the same issue, the second time it shows the GIF is not playing.

Did it work for you?

You might try first clearing the image and then setting. Sorta like this:

 $w('#gif').src = null;
 $w('#gif').src = "some gif";

This might reset the GIF.