Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to embed a video in my thesis using the media9 package and have found that the behaviour of the mediacommand playPause changes depending on whether the embedded file is a swf or mp4 format.

For an SWF file the video is only paused when the mouse-button is held down while for an MP4 file a single mouse-click pauses the video.

Does anyone know why the behaviour is different and what I need to do to get the mp4 behaviour for SWF files?

(I realise that the obvious answer is to convert my SWF file to MP4 however I have spent the better part of 6 hrs trying to do that. Although I can convert the file using ffmpeg, for some reason it doesn't display once embedded even though the example file included with media9 does.)

A MWE showing the difference in behaviour is as follows. Note that I'm using MiKTeX 2.9, pdfTeX and TeXnicCenter all (re)installed a couple of weeks ago.


\documentclass{article}
\usepackage{media9}
\usepackage[english]{babel}

\begin{document}

\includemedia[label=test,addresource=contours.swf,activate=pagevisible,
              width=9cm,height=10cm,flashvars={source=test.swf&autoPlay=true&loop=true}]
              {}{contours.swf}
\mediabutton[mediacommand=test:playPause]{\fbox{Play/Pause}}

\includemedia[label=random,addresource=random.mp4,activate=pagevisible,
              width=9cm,height=10cm,flashvars={source=random.mp4&autoPlay=true&loop=true}]
              {}{VPlayer.swf}
\mediabutton[mediacommand=random:playPause]{\fbox{Play/Pause}}

\end{document}

The above contours.swf file may be accessed at this link.

Any help will be greatly appreciated.

share|improve this question
    
Welcome to TeX.sx! You can upload the video to a sharing service (such as dropBox or equivalent) and add the link to your post. This way anyone capable of providing assistance can download it. –  Peter Jansson Mar 3 '13 at 15:17
    
Thanks Peter. I've added a link to the file. –  luke Mar 4 '13 at 1:11
    
Indeed FFmpeg, is not able to recode the SWF into MP4. Could you try to produce it in another intermediate file format, say MPEG or uncompressed AVI? –  AlexG Mar 4 '13 at 11:51
add comment

1 Answer

up vote 2 down vote accepted

The playPause media command can only be executed by VPlayer.swf loaded in the RichMedia Annotation labelled random.

playPause is one of a small number of interface functions (API) implemented in VPlayer.swf (and APlayer.swf, by the way). You may have a look into the sources VPlayer.mxml and APlayer.mxml that ship with media9.

If you wanted to add API functions to contours.swf, you would have to program them in ActionScript, which is the programming language behind Flash, and compile them into contours.swf. Interface functions are added to a Flash application by means of the ExternalInterface.addCallback(...) ActionScript method.

The reason why your swf pauses while pressing the mouse button is that you simply keep AdobeReader busy by this action. You could press the button anywhere on the page with the same effect. You don't really call a dedicated function within your SWF.

BTW, the YouTube Player (see first example in the documentation media9.pdf) provides a completely different set of interface functions (documented here). playPause isn't implemented there either, but playVideo and pauseVideo are, amongst others. Thus, you would have to insert two \mediabuttons for pausing and resuming playback:

\includemedia[
  label=yt1,
  width=0.6\linewidth,height=0.45\linewidth,
  activate=pageopen,
  flashvars={
    enablejsapi=1    % enables yt player api used in media buttons
  }
]{}{https://www.youtube.com/v/Mdc3o7wOwNA?rel=0}   % online Flash file (YouTube Player)

\mediabutton[mediacommand=yt1:playVideo]{\fbox{\strut Play}}
\mediabutton[mediacommand=yt1:pauseVideo]{\fbox{\strut Pause}

PS: contours.swf doesn't need to be added as a resource, it is already the main Flash application executed by activating the RichMedia Annotation.

How did you create contours.swf? FFmpeg can't decode it.

share|improve this answer
    
Alex, thanks for your reply, unfortunately I'm now not sure how best to proceed. I created contours.swf using TecPlot360 which is a software package used for visualisation of large scientific computational datasets (e.g. CFD, FEA results) –  luke Mar 4 '13 at 12:08
    
@luke: Pleased to meet you, I am using CFD myself, don't have experience with TecPlot, though. Can you tell TecPlot to output numbered bitmap sequences instead of SWF? I am pretty sure this should be possible. –  AlexG Mar 4 '13 at 12:13
    
the available file formats are avi, flv, swf, mpeg-4, raster metafile and wmv. Yesterday I tried exporting to avi and using FFmpeg to convert to mp4 (with libx264 as recommended in the media9 manual) but once embedded the movie would only show a blank page. –  luke Mar 4 '13 at 12:25
    
@luke. Try FLV. It is supported by the FlashPlayer plug-in and thus by VPlayer.swf. Make sure the file name used in the addresource option is the same as the one used with the source FlashVar. –  AlexG Mar 4 '13 at 12:29
    
that seems to have worked!! I could have sworn that I tried that yesterday... though, after several hours of stuffing around and googling I was pretty tired and frustrated. Thanks very much. –  luke Mar 4 '13 at 12:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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