-
Notifications
You must be signed in to change notification settings - Fork 89
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Play embedded media with xelatex #253
Comments
If I recall correctly, the issue is the way in which the video file is embedded, which differs from across different packages. media9 wraps the movie in a flash media-player object which makes it very annoying.
I think the main appeal was to have a media player with the same functionality, look & feel, etc. across all platforms and PDF readers. Alternatives are:
|
The \documentclass{beamer}
\usepackage{xkeyval}
\usepackage{zref-abspage}
\usepackage[bigfiles]{pdfbase}
% Written by Fritz -- https://tex.stackexchange.com/a/592827-- using Adobe PDF Reference, sixth edition, Nov. 2006
% Usage: \simplemedia[<options>]{<poster or text>}{<media file>}{MIME type}
\makeatletter
\define@boolkey{simplemedia}{autoplay}{\def\simplemediaautoplay{#1}}
\define@boolkey{simplemedia}{showGUI}{\def\simplemediashowGUI{#1}}
\presetkeys{simplemedia}{autoplay=false,showGUI=false}{}
\ExplSyntaxOn
\newcommand\simplemedia[4][]{%
\setkeys{simplemedia}{#1}\leavevmode
\pbs_pdfobj:nnn{}{fstream}{{}{#3}} % EmbeddedFiles stream
\pbs_pdfobj:nnn{}{dict}{/Type/Filespec/F~(#3)/UF~(#3)/EF~<</F~\pbs_pdflastobj:>>} % File specification dictionary
\pbs_pdfobj:nnn{}{dict}{/CT~(#4)/D~\pbs_pdflastobj:/N~(Media~clip~from~#3)/P~<</TF (TEMPACCESS)>>/S~/MCD} % Content type dictionary
% XXX: /A below is incorrectly interpreted by Pympress as autoplay instead of play-on-activate and using the Additional Actions (AA) dictionary for autoplay
\pbs_pdfobj:nnn{}{dict}{/C~\pbs_pdflastobj:/N~(Rendition~from~#3)/P~<</BE~<</C~\simplemediashowGUI~/A~\simplemediaautoplay>>~>>/S~/MR} % media clip dictionary
\tl_set:Nx\mediarendition{\pbs_pdflastobj:}% Save ID of Rendition annotation
\pbs_pdfobj:nnn{}{dict}{}\tl_set:Nx\renditionactionplay{\pbs_pdflastobj:}% Reserve ID for Play Rendition action
\pbs_pdfobj:nnn{}{dict}{}\tl_set:Nx\renditionactionstop{\pbs_pdflastobj:}% Reserve ID for Stop Rendition action
\hbox_set:Nn\l_tmpa_box{#2}% Compute size of poster
\tl_set:Nx\l_box_wd_tl{\dim_use:N\box_wd:N\l_tmpa_box}
\tl_set:Nx\l_box_ht_tl{\dim_use:N\box_ht:N\l_tmpa_box}
\tl_set:Nx\l_box_dp_tl{\dim_use:N\box_dp:N\l_tmpa_box}
\pbs_pdfxform:nnnnn{1}{1}{}{}{\l_tmpa_box}
\tl_set:Nx\l_simplem_current_page_tl{\zref@extract{simplem@\int_use:N\g_simplem_id_int}{abspage}}
\pbs_pdfannot:nnnn{\l_box_wd_tl}{\l_box_ht_tl}{\l_box_dp_tl}{
/T~(Annotation~from~#3)~/Subtype~/Screen~/BS~<</W~1/S/S>>/C~[0.039216~0.039216~0.039216]/CA~1/F~4~%
/Contents~(Embedded~media~file~#3)/NM~(simplemediascreenannot:#3)/AP~<</N~\pbs_pdflastxform:>>%
/A~\renditionactionplay~/AA~<<\ifKV@simplemedia@autoplay~/PO~\renditionactionplay~\fi~/PC~\renditionactionstop~>>~%
\int_compare:nT{\l_simplem_current_page_tl>0}{/P~\exp_args:Ne\pdf_pageobject_ref:n{\l_simplem_current_page_tl}}%
}
\pbs_pdfobj:nnn{\renditionactionplay}{dict}{/R~\mediarendition/S~/Rendition/OP~4/AN~\pbs_pdflastann:} % Rendition Action: "Play Rendition"
\pbs_pdfobj:nnn{\renditionactionstop}{dict}{/R~\mediarendition/S~/Rendition/OP~1/AN~\pbs_pdflastann:} % Rendition Action: "Stop Rendition"
\phantom{#2} % Display the poster
\zref@labelbyprops{simplem@\int_use:N\g_simplem_id_int}{abspage}\int_gincr:N\g_simplem_id_int
}%
\int_new:N\g_simplem_id_int
\ExplSyntaxOff
\makeatother
\begin{document}
\begin{frame}
\frametitle{play on click}
\begin{center}
\simplemedia{\includegraphics[width=5cm]{example.png}}{example.mp4}{video/mp4}
\end{center}
\end{frame}
\begin{frame}
\frametitle{autoplay}
\begin{center}
\simplemedia[autoplay=true]{\includegraphics[width=5cm]{example.png}}{example.mp4}{video/mp4}
\end{center}
\end{frame}
\begin{frame}
\frametitle{show GUI}
\begin{center}
\simplemedia[showGUI=true]{\includegraphics[width=5cm]{example.png}}{example.mp4}{video/mp4}
\end{center}
\end{frame}
\end{document} When pympress is fixed, and to have correct behaviour on other PDF players, |
This is great, thank you so much for your efforts! Once the bug is fixed, could you release a new version, please? |
Once it’s fixed I will update this code and put it somewhere in the documentation. However, the fix is likely going to either not be easy, or to break autoplay, so I may hold off for a while. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
First of all, thank you for making this awesome tool! I am using it regularly for my presentations at uni and am unbelievably happy with it. There is just one tiny thing I am struggling with: embedding media.
At the moment, it seems like you can't embed audio or video files with xelatex in such a way that it is played by
pympress
. The reason for this is that themultimedia
package, for which there are examples in the README-file, does not work with xelatex, throwing error messages, and media embedded usingmedia9
, which does work with xelatex, is not clickable inpympress
(although it is in otherpdf
viewers such asOkular
). Thus, I have two questions:pympress
supports the packagemedia9
? It seems to be the newest, most versatile and most popular package for embedding media files in beamer.If I can be of any help, feel free to let me know!
The text was updated successfully, but these errors were encountered: