Thank you all for your replies.

I found an interesting site on how to work with the animated gifs.

http://www.xcelfiles.com/AnimatedGif.html

But I still can't get it to work with my specific code, I'll keep trying.