GeneralInformational Text for embedded Media Files

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

Informational Text for embedded Media Files

Post by Linguist »

I'm using the media9 package to embed MP3 files into my linguistics thesis.

Is it possible with the draft option of media9 to display <poster text> rather than "a box [...] that has the dimensions of <poster text>"?

A typical example from my thesis is the following, where <poster text> contains important information for the reader; a reference to a line in a text in the appendix.

Code: Select all

\documentclass{article}
\usepackage[draft]{media9}

\begin{document}
  \includemedia[
    transparent,
    addresource=130905-1-00-29-5.mp3,  % <media file>
    flashvars={
      source=130905-1-00-29-5.mp3  % <media file>
      &autoPlay=true
      &hideBar=true
    }
  ]{(130905-1, 0:29.5)}{APlayer.swf} % <poster text>	
\end{document}
Once my thesis is finished, I want to produce two pdfs; one with embedded sound files, and one without sound files.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Informational Text for embedded Media Files

Post by hugovdberg »

You could perhaps define a new macro instead of using the draft option (which simply honours the default draft behaviour for documents):

Code: Select all

\documentclass{article}
\usepackage{media9} %don't use draft option

\newif\ifincludeexternalmedia % declare new switch
\includeexternalmediatrue %comment or use \includeexternalmediafalse to display poster text
\newcommand{\includemediaorposter}[3]{% New command takes three required arguments, first can be empty
   \ifincludeexternalmedia % Use include media
      \includemedia[#1]{#2}{#3}
   \else % Just display poster text
      #2
   \fi   
   }


\begin{document}
  \includemediaorposter{ % USE CURLY BRACKETS for first argument
    transparent,
    addresource=130905-1-00-29-5.mp3,  % <media file>
    flashvars={
      source=130905-1-00-29-5.mp3  % <media file>
      &autoPlay=true
      &hideBar=true
    }
  }{(130905-1, 0:29.5)}{APlayer.swf} % <poster text>    
\end{document}
You could also extend \includemediaorposter with a fourth argument if you want to display different poster text when not including media
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
Linguist
Posts: 43
Joined: Mon Nov 07, 2011 12:07 pm

Re: Informational Text for embedded Media Files

Post by Linguist »

Thanks, this is exactly what I wanted!

Could you post the code for how I'd extend \includemediaorposter to display different poster text depending on whether or not the media is included?
hugovdberg
Posts: 133
Joined: Sat Feb 25, 2012 6:12 pm

Informational Text for embedded Media Files

Post by hugovdberg »

That is actually really simple, make the \includemediaorposter take 4 arguments instead of 3, and provide the text to include as fourth argument in the document:

Code: Select all

\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[#1]{#2}{#3}
   \else % Just display poster text
      #4
   \fi   
   }


\begin{document}
  \includemediaorposter{ % USE CURLY BRACKETS for first argument
    transparent,
    addresource=130905-1-00-29-5.mp3,  % <media file>
    flashvars={
      source=130905-1-00-29-5.mp3  % <media file>
      &autoPlay=true
      &hideBar=true
    }
  }{(130905-1, 0:29.5)}{APlayer.swf}{Text when no media is included} % <poster text>    
\end{document}
Ubuntu 13.10 + Tex Live 2013 + Texmaker / Windows 7 Pro + MikTex 2.9 + TexnicCenter / Android 4.3 + TexPortal + DroidEdit
Post Reply