[Tex/LaTex] show only play button with animategraphics

animategif

I transformed a gif in a serie of png files and I animated it in my pdf with the command \animategraphics. I want to have only a play button shown, not all the controls. Is there a way of doing this?

Here is the full command that I used at the moment:

\animategraphics[loop,width=\textwidth]{50}{./figures/sim_gif/res_gl_animation_}{0}{399}

Thanks.

Edit:

Here's a MWE:

\documentclass[letterpaper, 12pt, final]{article}
\usepackage{graphicx}
\usepackage{animate}

\begin{document}

\begin{figure}
    \centering
    \animategraphics[loop,width=\textwidth]{50}{./figures/sim_gif/res_gl_animation_}{0}{399}
    \caption{Some animation for MWE}
\end{figure}

\end{document}

Best Answer

Specific buttons from the available set of controls can be selected as follows:

con­trols[=all | true | on]                 % show all avail­able but­tons
con­trols=none | false | off                % hide them all
con­trols={[play][, step][, stop][, speed]} % show se­lected

Thus, to show the play button alone,

controls=play

is sufficient.

Example:

\documentclass{article}

\usepackage{animate}
\usepackage{graphicx}

\begin{document}
\animategraphics[
  controls=play,
  width=1in,loop
]{1}{example-image-a4-numbered}{}{}
\end{document}

Alternatively, the JS API of animate can be used. It gives access to the animation objects in a PDF file.

The \mediabutton command from the media9 package can be used to create custom buttons as in the code listed below.

Instead of Play/Pause strings, you can \includegraphics image files as button faces for the Play and Pause buttons, or draw something with TikZ.

A single toggle button for play-pausing an animation is given in Fig. 1 in the animate docs. Here, two buttons, one for play, another for pause are inserted below the animation:

\documentclass[letterpaper, 12pt, final]{article}
\usepackage{graphicx}
\usepackage{animate}
\usepackage{media9}

\begin{document}

\begin{figure}
    \centering
    \animategraphics[label=myAnim,loop,width=\textwidth]{50}{./figures/sim_gif/res_gl_animation_}{0}{399}

    \mediabutton[jsaction={anim.myAnim.playFwd();}]{\fbox{\strut Play}}
    \mediabutton[jsaction={anim.myAnim.pause();}]{\fbox{\strut Pause}}
    \caption{Some animation for MWE}
\end{figure}

\end{document}

Note that 50 frames per second, as specified in OP's example, is way too much and will hardly be achieved by AdobeReader. FPS 20 is sufficient for smooth playback (FPS 25 is a typical value for video encoding) and can be achieved if the image files are not too big and complex.

Related Question