Reload an animated gif

581 views
Skip to first unread message

ecme...@gmail.com

unread,
Oct 4, 2013, 4:44:42 PM10/4/13
to shiny-...@googlegroups.com
Dear all,

I have recently been enjoying shiny for some simple web apps and have run into an issue with animated gifs.  I have searched and not found an answer, and I apologize if I missed something obvious.

I would like to display an animated gif multiple times in sequence.  My problem is that the animation is displayed only once, and subsequent displays of the gif only show the final frame.  I do not want the gif file to loop over and over again, so I wonder whether there is a way to reload the file on each display.  As a workaround, I could probably create multiple copies of the same gif file.  But I wonder if there is a more elegant way.

As a simple example of the issue (two animated gifs repeatedly displayed one after the other), see

runGist(6832180)

Thanks,
Ed

ecme...@gmail.com

unread,
Oct 16, 2013, 11:08:11 AM10/16/13
to shiny-...@googlegroups.com
To answer my own post above, it looks like there are some caching features that I didn't fully understand.  In particular:

1. It seems that, if an animated gif has already been displayed in a shiny app, the animation cannot be repeated (assuming the gif does not loop).

2. If you create a copy of the original animated gif (same file, different filename), shiny seems to recognize that the copy is identical to the original.  When the animation displays for one of these files in a shiny app, the animation from both files cease to display thereafter (this is the caching part that I don't fully understand).

3. To get the same animation to display twice, I had to create two animated gifs, with one having a slightly smaller dimension than the other.  Now, the file sizes differ and they are not recognized as identical.

Joe Cheng

unread,
Oct 17, 2013, 2:31:07 PM10/17/13
to ecme...@gmail.com, shiny-...@googlegroups.com
You're right, Shiny ignores filenames in this case. However I think it might work to add another field that does vary (I haven't tried it so I don't know if it will work):


list(src=fname,contentType="image/gif",nonce=runif(1))


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages