LaTeX forum ⇒ GeneralShortcut 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

Postby Linguist » Tue Mar 04, 2014 7:10 am

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.
  1. \includemedia{
  2. transparent,
  3. addresource=<file name>,
  4. flashvars={source=<file name> &autoPlay=true &hideBar=true}
  5. }{\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

Postby hugovdberg » Tue Mar 04, 2014 5:17 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:

  1. \documentclass{article}
  2. \usepackage{media9} %don't use draft option
  3.  
  4. \newif\ifincludeexternalmedia % declare new switch
  5. \includeexternalmediatrue %comment or use \includeexternalmediafalse to display poster text
  6. %% Usage: \includemediaorposter{options for \includemedia}{poster text}{media}{no media text}
  7. \newcommand{\includemediaorposter}[4]{
  8. \ifincludeexternalmedia % Use include media
  9. \includemedia[
  10. transparent,
  11. addresource=#1, % <media file>
  12. flashvars={
  13. source=#1 % <media file>
  14. &autoPlay=true
  15. &hideBar=true
  16. }
  17. ]{#2}{#3}
  18. \else % Just display poster text
  19. #4
  20. \fi
  21. }
  22.  
  23.  
  24. \begin{document}
  25. \includemediaorposter{130905-1-00-29-5.mp3}{(130905-1, 0:29.5)}{APlayer.swf}{Text when no media is included}
  26. \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

Postby Linguist » Wed Mar 05, 2014 12:51 am

Of course... It seems so obvious now it's been suggested!

Thanks hugovdberg; you've been a great help!


Return to “General”

Who is online

Users browsing this forum: No registered users and 5 guests