[Tex/LaTex] Automatic pausing of video with media9

beamermedia9multimedia

Is there a way I can pause an embedded beamer video at some specified time point?

Video Playing Code (media9):

\includemedia[
width=\textwidth,height=0.5625\textwidth,
addresource=video.mp4, 
flashvars={
source=video.mp4
&loop=true 
&scaleMode=letterbox 
}
]{}{VPlayer.swf}

I can probably split the video into two, have the first half play, then play the second half on click. But I am wondering if there is an easier solution?

Best Answer

You can insert a custom play button which also starts a (JavaScript-) timer to pause the video after a given time-out. In the example below, the video pauses 10 s after the play button has been pressed.

playPause and pause are ActionScript functions of VPlayer.swf which are exposed to the JavaScript engine of Adobe Reader. There are two ways of calling them from within \mediabuttons, either via the mediacommand option or in a jsaction script, passed as argument to the callAS (=call ActionScript) method of the AnnotRichMedia object.

\includemedia[
  label=myvideo,
  width=\textwidth,height=0.5625\textwidth,
  addresource=video.mp4, 
  flashvars={
    source=video.mp4
%    loop % disabled 
    &scaleMode=letterbox 
  }
]{}{VPlayer.swf}

\mediabutton[
  mediacommand=myvideo:playPause,
  jsaction=myvideo:{
    try{app.clearTimeOut(tout)}catch(e){} % kill pending timers
    var tout=app.setTimeOut('annotRM.myvideo.callAS("pause")', 10000);
  }
]{\fbox{Play/Pause}}
Related Question