## LaTeX forum ⇒ General ⇒ Shortcut for Media File Topic is solved

LaTeX specific issues not fitting into one of the other forums of this category.
Linguist
Posts: 39
Joined: Mon Nov 07, 2011 12:07 pm

### Shortcut for Media File  Topic is solved

Hello,

I'm writing my linguistics thesis in which I plan on embedding a number of sound files. I use the same code to embed each file, the only difference being the name of the MP3 file.

Is it possible to define a shortcut to reduce the length of the code I use each time I embed a file? I currently embed sound files with the following code.
\includemedia{   transparent,   addresource=<file name>,   flashvars={source=<file name> &autoPlay=true &hideBar=true}}{\speaker{}}{APlayer.swf}

{\speaker{}} is a predefined shortcut for the icon I use as the <poster text>. I use the same poster text for each sound file.

Ideally I'd like to be able have something like \embed{<filename>}. But any solutions that significantly reduce the length of my code would be welcomed.

Tags:

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm
You could use the code I posted previously with the alternative text in "draft"-mode, and then move the default options into the definition of the \includemediaorposter command:

\documentclass{article}\usepackage{media9} %don't use draft option \newif\ifincludeexternalmedia % declare new switch\includeexternalmediatrue %comment or use \includeexternalmediafalse to display poster text%% Usage: \includemediaorposter{options for \includemedia}{poster text}{media}{no media text}\newcommand{\includemediaorposter}[4]{    \ifincludeexternalmedia % Use include media       \includemedia[          transparent,          addresource=#1,  % <media file>          flashvars={            source=#1  % <media file>            &autoPlay=true            &hideBar=true            }          ]{#2}{#3}    \else % Just display poster text       #4    \fi       }  \begin{document}   \includemediaorposter{130905-1-00-29-5.mp3}{(130905-1, 0:29.5)}{APlayer.swf}{Text when no media is included}\end{document}
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit

Linguist
Posts: 39
Joined: Mon Nov 07, 2011 12:07 pm
Of course... It seems so obvious now it's been suggested!

Thanks hugovdberg; you've been a great help!