animateinline
and \animategraphics
cannot be nested.
Use TikZ nodes to align the image parts:
\documentclass[varwidth]{standalone}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{animate}
\begin{document}
\begin{animateinline}[controls,loop,scale=0.3]{25}
\multiframe{60}{i=0+1}{
\begin{tikzpicture}[inner sep=0,outer sep=0]
\node at (0,0) {\includegraphics{down}};
\ifthenelse{\i<15 \OR \i>45}{
% stick in front of magnet
\node at (-2,0.4) {\includegraphics{magnet}};
\node at (-2,4.05) {\includegraphics{stick-\i}};
}{
% stick behind magnet
\node at (-2,4.05) {\includegraphics{stick-\i}};
\node at (-2,0.4) {\includegraphics{magnet}};
}
\end{tikzpicture}
}
\end{animateinline}\\[1ex]
\small Images: \textcopyright\ National High Magnetic Field Laboratory
\end{document}
The images of the original example were downloaded and renamed with this shell script:
#!/bin/bash
for i in {0..59}
do
wget https://nationalmaglab.org/html5/MagLabU/source/faradaymotor/images/stickFrames/stick%20\($i\).png
mv stick\ \($i\).png stick-$i.png
done
wget https://nationalmaglab.org/html5/MagLabU/source/faradaymotor/images/down.png
wget https://nationalmaglab.org/html5/MagLabU/source/faradaymotor/images/magnet.png