[Tex/LaTex] Is it possible to embed a YouTube video using LaTeX

embeddingmovie15pdftex

I'd like to embed a YouTube video inside a PDF generated by LaTeX, now I know it is possible to embed videos using the movie15 package but that includes the video in the PDF.

I was hoping there would be some way to embed the video as a flash object that streams it from YouTube when you get to the slide.

Anyone managed to do it before?

Best Answer

Notice of obsolescence:

YouTube have dropped its Flash-based video player in Sept 2017. For the lack of HTML5 support in the PDF specification (and thus by PDF viewers), YT playback is not possible anymore in an embedded fashion.

\documentclass{article}
\usepackage{media9}             %pdflatex, latex+dvips+ps2pdf, xelatex
%\usepackage[dvipdfmx]{media9}  %latex+dvipdfmx

\begin{document}
\includemedia[
  width=0.6\linewidth,height=0.45\linewidth,
  activate=pageopen,
  flashvars={
    modestbranding=1 % no YT logo in control bar
   &autohide=1       % controlbar autohide
   &showinfo=0       % no title and other info before start
  }
]{}{http://www.youtube.com/v/<video id>?rel=0}   % Flash file
\end{document}

<video id> to be replaced by the video ID, i. e., something like Mdc3o7wOwNA. More FlashVars for configuring the youtube video player are documented here. Some FlashVars, such as rel=0, seem to have effect only if appended to the URL.

Related Question