Skip to content

Instantly share code, notes, and snippets.

Created January 26, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/e6b7051cf270594d2b38 to your computer and use it in GitHub Desktop.
Save anonymous/e6b7051cf270594d2b38 to your computer and use it in GitHub Desktop.
test presentation
\documentclass{beamer}
% \usepackage{multimedia} % \movie
\usepackage{media9}[2013/11/04] % ‘media9’ package replaces the now obsolete ‘movie15’ package.
\usepackage{tikz}
\usepackage{animate}
% make as "plain Latex" style/theme for Beamer as possible
\usetheme{default} % empty
\usefonttheme{serif} % computer modern font
\setbeamercolor{structure}{fg=black} % reset colors
\setbeamertemplate{navigation symbols}{}%remove navigation symbols
% centered frame title
\setbeamerfont{frametitle}{size=\large,series=\bfseries}
% does for all!
\setbeamertemplate{frametitle}{ %
\begin{centering}
\insertframetitle
\par
\end{centering}
}
\def\choicetransition{\transdissolve[duration=0.5]}
% \def\choicetransition{\transsplitverticalout[duration=0.5]} % not visible?
% \def\choicetransition{\transwipe[direction=90,duration=0.5]} % not visible?
\begin{document}
\title{Testing a timed presentation, with animation and video}
\author{My Author}
\date{2015}
% slide 01
% [https://groups.google.com/forum/?_escaped_fragment_=topic/comp.text.tex/kPw6PR2Ejbk#!topic/comp.text.tex/kPw6PR2Ejbk autoplay an animation in pdf document - Google Grupper]
% http://tex.stackexchange.com/questions/149804/rotating-a-one-page-float-for-pdf-viewing: \afterpage{\global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 0}}
% \pdfpageattr{/AA << % here it appears - but it has no text :( looks like frozen, but the window can be removed with space.. AND - unfortunately it runs on every page :( For some reason, the text appears only on the page with video?!
% also check: http://tex.stackexchange.com/questions/152358/animations-in-latex
% http://tex.stackexchange.com/questions/136666/exporting-animation-created-with-animate-package
% http://tex.stackexchange.com/questions/23727/converting-beamer-slides-to-animated-images/108592#108592
% http://tex.stackexchange.com/questions/40332/how-can-i-set-a-time-between-slides-to-create-an-automatic-slideshow-with-beamer
% http://tex.stackexchange.com/questions/67663/did-anyone-succeed-in-playing-embedded-movies-inside-acrobat-in-linux
% http://tex.stackexchange.com/questions/122092/inject-javascript-with-pdflatex-etc-for-page-level-events
% http://tex.stackexchange.com/questions/72714/adjusting-the-framerate-with-the-animate-package
% http://tex.stackexchange.com/questions/149804/rotating-a-one-page-float-for-pdf-viewing: \afterpage{\global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 0}}
\frame{ \choicetransition \transduration{1.5} %
% \pdfpageattr{/AA << %nowork here..
\titlepage %
}
% slide 02
% \pdfpageattr{/AA << %here it appears from page 2 onwards
% \pdfpageattr{/AA << %additional actions for pages
% this.pageNum is 3 for page 4!
% same thing with \expandafter{\the\pdfpageattr - all pages:
\pdfpageattr\expandafter{\the\pdfpageattr /AA <<
%on every page open event, call ActionScript method 'play' exposed by APlayer.swf
%/O << /S/JavaScript /JS (annotRM['my_sound'].callAS('play');) >>
%do something else on every page close event
% /C << /S/JavaScript /JS (app.alert('Page '+ this.pageNum + ' is being left.');) >>
/O << /S/JavaScript /JS (
%app.alert('Page '+ this.pageNum + ' is being entered. ' + ((this.pageNum==3) ? annotRM['myvideo'] : ".") );
if (this.pageNum==3) {
% app.alert('Page ' + this.pageNum); % shows
/*annotRM['myvideo'].callAS('seek', 32.1); // don't use //, else "SyntaxError: missing \} in compound statement" */
%annotRM['myvideo'].callAS('play'); % nothing
%console.println(annotRM.myvideo.callAS('play')); % doesn't raise at this point
%app.alert(annotRM.myvideo.callAS('play')); % this doesn't show
% app.alert("Starting " + typeof(annotRM['myvideo']) + " " + annotRM['myvideo'].activated); % shows; typeof(annotRM['myvideo'])=object; .activated=true
%ret = annotRM.myvideo.callAS('play'); % breaks alert("Done");
%ret = annotRM['myvideo'].callAS('play'); % breaks alert("Done");
% app.alert("Done"); % does not show, if AS breaks previously
}
%\keys_set:nn { media9/mbtn }{mediacommand,myvideo:play} % nope
) >>
>>}
% NB: in pdf, this ends up as: /JS ( if \(this.pageNum==3\) { app.alert\('Page ' + this.pageNum\); /*annotRM['myvideo'].callAS\('seek', 32.1\); // don't use //, else "SyntaxError: missing } in compound statement" */ app.alert\("Starting"\); app.alert\("Done"\); }
\begin{frame}[plain] \choicetransition \transduration{1.5} %
\begin{center}%
\Large
Hello there\\[1em]
Just trying a plain old frame out
\end{center}%
\end{frame}
% slide 03: animation
\begin{frame} \choicetransition \transduration{2.5} %
\frametitle{Testing an animation}
% last argument of animateinline is frame rate
\begin{animateinline}[controls=false,autoplay,loop=false]{4}
\multiframe{8}{n=-0.4+0.1}{
\begin{tikzpicture}[scale=10,rotate=90]
\draw[blue,opacity=0.5] (-.1,-.2) rectangle (.4,0.2);
\draw[red] (-.1,-.2) -- (-.3,\n);
\end{tikzpicture}
}
\end{animateinline}
\end{frame}
% slide 04: video
% wget http://archive.org/download/Elephants_Dream_teaser_2/elephantsdream_teaser.ogv
% mencoder elephantsdream_teaser.ogv -ovc lavc -oac mp3lame -o elephantsdream_teaser.avi
% ffmpeg -i elephantsdream_teaser.ogv -c:v libx264 -crf 19 elephantsdream_teaser.flv # new, `-c:v`, `-preset fast`, `-profile baseline`, `-x264opts` nowork 4me
% ffmpeg -i elephantsdream_teaser.ogv -vcodec libx264 -profile baseline -x264opts bitrate=300 -s 320x240 -r 12 -g 12 -acodec libmp3lame -ar 44100 -f flv elephantsdream_teaser.flv # nowork 4me
% ffmpeg -i elephantsdream_teaser.ogv elephantsdream_teaser.flv % makes audio Vorbis
% mencoder elephantsdream_teaser.ogv -ovc x264 -oac mp3lame -o elephantsdream_teaser.flv % work4me; but mediainfo format: AVI, should be Flash Video; Video: Sorenson Spark & Audio: MPEG Audio
% ffmpeg -i elephantsdream_teaser.ogv -acodec pcm_s16le -r 24 -g 24 elephantsdream_teaser.flv % Format: Flash Video, Video: Sorenson Spark, Audio: PCM
\begin{frame} \choicetransition \transduration{5.5} %
\frametitle{Testing a video}
% \movie[width=3cm,height=2cm,poster,autostart,start=5s,duration=2s,once]{}{elephantsdream_teaser.flv} % nowork, even w/ acroread 9.4.1
\includemedia[
label=myvideo, % defines JavaScript object annotRM['myvideo']
width=0.6\linewidth,height=0.6\linewidth,
activate=pagevisible,
deactivate=pageinvisible,
transparent,
addresource=elephantsdream_teaser.flv,
flashvars={
source=elephantsdream_teaser.flv % same path as in addresource!
&autoPlay=true %
%&seek=20 % from 20 seconds offset (nowork); also seek
%&play=20 % from 20 seconds offset (nowork); also seek
%&pause=22 % to 22 seconds offset into the media file
%%&hideBar=true %
%&autohide=1 % controlbar autohide
&loop=false % loop video
&scaleMode=letterbox % preserve aspect ratio
}
]{}{VPlayer9.swf} %VPlayer.swf doesn't show video at all! Not even a frame - just white background!
% must enable https://acrobatusers.com/tutorials/javascript_console to show on error for these:
\PushButton[ %requires package ‘hyperref’
name=thibut,
onclick={ % SyntaxError: missing : after property id if there isn't a comma between the args here!
%annotRM['my_vid'].activated=true;
% annotRM.myvideo.callAS("seek", 12.3);
%annotRM['my_vid'].callAS('seek', 20.3);
%('playPause');
console.show();
console.println('-------------');
console.println(annotRM.myvideo);
console.println(annotRM['myvideo']); % object AnnotRichMedia
console.println(annotRM['myvideo'].activated);
annotRM['myvideo'].activated=true;
% console.println(annotRM['myvideo']:callAS("seek", 12.3)); % SyntaxError: missing ) after argument list
% console.println(annotRM['myvideo']:callAS("seek", [(12.3)]); % runaway argument
% console.println(annotRM['myvideo']:callAS("seek", 12.3))); % runaway argument
% console.println(annotRM['myvideo'].seek(12.3)); % annotRM.myvideo.seek is not a function
function listProperties(obj) {
var propList = "";
for(var propName in obj) {
if(typeof(obj[propName]) != "undefined") {
propList += (propName + ", ");
}
}
console.println(propList);
}
listProperties(annotRM['myvideo']); % callAS, activated, name, page, subtype, rect, context3D,
},
format={
console.show();
console.println('-------------');
},
]{\fbox{Test}} % nowork
\mediabutton[%
mediacommand=myvideo:seek [(32.1)],% ok
% jsaction=myvideo:{annotRM['myvideo'].seek(20.1);}% nowork, and raises js console,
% jsaction=myvideo:{annotRM['myvideo'].callAS("seek", 12.3);}% nowork,
% jsaction=myvideo:{annotRM['myvideo']:callAS("seek", 12.3);}% nowork, invalid label
% jsaction=myvideo:{app.alert("Test " + typeof(annotRM['myvideo']));} % works, prints 'object'
]{\color{blue}\fbox{SEEK}} % works, but is invisible in acroread 9.4.1 (and visible in evince?)?
\end{frame}
% mediabutton adds this in PDF stream:
% 104 0 obj
% <<
% /JS (if\(typeof\(annotRM\)=='undefined'\){annotRM=new Array\(\);}if\(typeof\(annotRM['myvideo'
% ]\)=='undefined'\){annotRM['myvideo']=this.getAnnotRichMedia\(3,'myvideo'\);}annotRM['myvideo'].activated=true;)
% /Next
% <<
% /TA 93 0 R
% /TI 89 0 R
% /CMD
% <<
% /C (seek)
% /A [(32.1)]
% >>
% /S /RichMediaExecute % The type of action that this dictionary describes;
% >>
% /S /JavaScript
% >>
% endobj
% slide 05: end
\begin{frame}[plain] \choicetransition \transduration{1.5} %
\begin{center}%
\LARGE
Fin
\end{center}%
\end{frame}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment