3

From this question, I see that it is possible to include remote images within a PDF, via the media9 package. Can direct inclusion of Javascript--as in this question--be used to update the image (technically, the swf object) at a specified interval?

  • 1
    I'll try and write a dedicated slideshow App for inclusion with media9. May take a while. – AlexG Mar 19 '15 at 11:52
3

Version [2015-05-11] of media9 provides SlideShow.swf which is an image gallery app for live and static remote (downloaded at viewing time) and static embedded image files in the PNG, JPEG and GIF formats. SlideShow.swf is configured via an XML file with very simple syntax.

The app can be interacted with using the right-click menu or the keyboard.

The link which follows is the slide-show example embedded in the media9 documentation file, opened in the web browser. (The fourth image doesn't work here because it uses a URL which is relative to the player SWF file):

http://mirrors.ctan.org/macros/latex/contrib/media9/players/SlideShow.swf?xml=../doc/files/config.xml

A minimal beamer-class example of a single-image "slide-show" using the remote live image URL given in the OP would read:

\documentclass{beamer}
\usepackage{media9}

\begin{document}
\begin{frame}{Live remote image}
  \includemedia[
    width=\linewidth,
    height=0.46\linewidth,
    activate=pageopen,
    passcontext, %show context menu
    addresource=show.xml,
    flashvars={ xml=show.xml }
  ]{}{SlideShow.swf}
\end{frame}
\end{document}

with file show.xml containing the lines:

<SlideShow>
  <Img live="3">
    <caption>Live remote image.</caption>
    <URL>http://dev.eightbeers.org/tex/corner-icon.png</URL>
  </Img>
</SlideShow>

The remote image will be refreshed every three seconds.

  • Works like a charm! I hope you enjoyed the test png :) – kyle May 17 '15 at 15:45
  • This is a tiny detail, but is it possible to remove the quarter-watch "loading" icon in the top-left of the graphic? – kyle May 17 '15 at 15:46
  • @kyle: Providing some kind of loading feedback isn't that bad an idea, I believe. It should move out of view when the mouse is moved out of the image display. – AlexG May 18 '15 at 7:08
  • @kyle: Would you mind making permanent the URL of the maw-the-lawn simulation? It is a great example of demonstrating live image display (I don't know of a better one). – AlexG May 18 '15 at 7:13
  • @kyle: Ok, in the next version the cursor will be explicitly hidden when the mouse is moved out. – AlexG May 18 '15 at 7:35
1

This question has a pretty solid answer. There are still issues with what happens when the object reloads (the entire graphic goes black while Reader fetches the content); anyone who has a suggestion for that, I'd be happy to hear.

MWE:

\documentclass{beamer}
\usepackage{media9}

\begin{document}                                                                                                    
    \begin{frame}{Test auto-updated input}{}
        \includemedia[                                                                                                      
            height=5cm,
            label=sample,
            width=11cm,
            activate=pageopen,
            flashvars={
                src=http://dev.eightbeers.org/tex/corner-icon.png
                &controlBarMode=none
            },
        ]{}{StrobeMediaPlayback.swf}% I'll be honest, not too sure about indentation in the following
\pdfannot width 0pt height 0pt depth 0pt {                                                                          
    /Subtype/Widget                                                                                                   
    /AA <</PO <<  %start updating routine on 'pageopen' event                                                                                                      
        /S/JavaScript/JS (                                                                                              
            try{var ret=app.setInterval('                                                                                 
                annotRM["sample"].activated=false;                                                                          
                annotRM["sample"].activated=true;                                                                           
            ' , 2500);}catch(e){}
        )
    >>>>
}
    \end{frame}                                                                                                         
\end{document}

If you have issues loading your own dynamic images:

  • StrobeMediaPlayback.swf will only load images if it recognizes the file suffix; so if you are building dynamic images in PHP you will need to use some .htaccess-fu to redirect from a .jpg or .png or the like
  • While most browsers play nicely when an image is sent without a Content-Length: header, StrobeMediaPlayback.swf will fail with the cryptic Argument Error - Invalid parameter passed to method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.