Skip to content
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

Support beamer’s multimedia package autostart #212

Open
Cimbali opened this issue Oct 18, 2021 · 15 comments
Open

Support beamer’s multimedia package autostart #212

Cimbali opened this issue Oct 18, 2021 · 15 comments
Labels
enhancement external dependency Progress on this issue is blocked by a bug or lacking feature in software on which we depend

Comments

@Cimbali
Copy link
Owner

Cimbali commented Oct 18, 2021

This question came up in #71.

From the multimedia.sty we can see that the autostart option of the \movie command is inserted with a WIDGET type annotation:

Roughly the relevant code is:

\beamer@pdfannot width \@tempdima height \@tempdimb depth \@tempdimc
{
  /Subtype /Movie
  /T (\mm@label)
  /Border [0 0 \mm@bw]
  /Movie << /F (#3) \mm@poster\space >>
  /A << \mm@start\space \mm@duration\space \mm@playmode\space \mm@controls\space >>
}%
\box\@tempboxa%
\ifmm@autostart%
  \immediate\beamer@pdfobj {<< /S /Movie /T (\mm@label) /Operation /Play >>}%
  \beamer@pdfannot width 0pt height 0pt depth 0pt {%
    /Subtype/Widget
    /FT/Btn/Ff 65537
    /T (wid@\mm@label)
    /AA <</PO \the\beamer@pdflastobj\space 0 R>>% attention: /O --> /PO for Widget annots
  }%
\fi%

So something like:

  • a PDF object (action?) that specifies which movie to play
  • a 0-sized widget (button?) that specifies an Additional Action /AA at Page Opening /PO which is the previous action

This means that to be able to do this,

  • either Poppler needs to export the AnnotWidget annotation class in the gobject bindings
  • or beamer’s multimedia package needs to use another mechanism to implement the autostart
@Cimbali Cimbali added enhancement external dependency Progress on this issue is blocked by a bug or lacking feature in software on which we depend labels Oct 18, 2021
@Cimbali
Copy link
Owner Author

Cimbali commented Oct 18, 2021

Note that the workaround to have the autoplay currently is to use the movie15 package (and ensure verions for pympress ≥ 1.7.0, poppler ≥ 21.04):

\documentclass{beamer}
\usepackage{movie15}
\begin{document}

\begin{frame}
  \begin{center}
    \includemovie[attach=false,autoplay,text={\includegraphics{files/mailto.png}}]{0.4\linewidth}{0.3\linewidth}{files/random.mpg}
  \end{center}
\end{frame}

\end{document}

@whoenig
Copy link

whoenig commented Nov 1, 2021

@ousia
Copy link
Contributor

ousia commented Nov 4, 2021

@Cimbali,

here you have another sample for play when the page is entered and stop when the page is left:
uncompressed PDF file.

The relevant PDF object reads:

11 0 obj
<<
  /Alt [ () (file not found) ]
  /CT (video/mp4)
  /D 9 0 R
  /N (myvideo)
  /P 10 0 R
  /S /MCD
  /Type /MediaClip
>>
endobj

12 0 obj
<<
  /C 11 0 R
  /N <FEFF006D00790076006900640065006F>
  /S /MR
  /Type /Rendition
>>
endobj

13 0 obj
<<
  /Type /Annot
  /A <<
    /AN 13 0 R
    /OP 0
    /R 12 0 R
    /S /Rendition
  >>
  /AA <<
    /PC <<
      /AN 13 0 R
      /OP 1
      /R 12 0 R
      /S /Rendition
    >>
    /PO <<
      /AN 13 0 R
      /OP 0
      /R 12 0 R
      /S /Rendition
    >>
  >>
  /Border [ 0 0 0 ]
  /P 14 0 R
  /Subtype /Screen
  /T <FEFF006D00790076006900640065006F>
  /Rect [ 10.36114 10.36114 435.5541 435.5541 ]
>>

I wonder whether this might be easier to implement.

BTW, this was generated with ConTeXt.

@Cimbali
Copy link
Owner Author

Cimbali commented Nov 4, 2021

The auto-play is already working on your example @ousia, on v1.7.0b1. (At least if there’s a single media, on page 2 − I might be missing another one?) If you want to share how this was generated with ConTeXt, i.e. a code snippet, that could be useful to other users.

@ousia
Copy link
Contributor

ousia commented Nov 4, 2021

The auto-play is already working on your example @ousia, on v1.7.0b1. (At least if there’s a single media, on page 2 − I might be missing another one?)

Many thanks for your reply, @Cimbali.

I checked the sample with the Windows binary of version 1.7b1 and video on page 2 didn’t start automatically (there is no other media in the PDF document).

I guess GStreamer (and its Python bindings) aren’t included in the binary, are they?

If you want to share how this was generated with ConTeXt, i.e. a code snippet, that could be useful to other users.

Of course. The source for the PDF sample reads:

\setupinteraction[state=start]
\starttext
 \null\page
 \startTEXpage[offset=10pt]
  \definerenderingwindow[myrenderingwindow]
    [width=\textwidth, height=\textwidth,
     openpageaction=StartRendering{\currentrendering},
     closepageaction=StopRendering{\currentrendering}]
  \userendering[myvideo][video/mp4][video.mp4]
    [embed=yes]
  \placerenderingwindow[myrenderingwindow][myvideo]
 \stopTEXpage
 \null\page
\stoptext

It requires a fairly recent version of ConTeXt LMTX.

@Cimbali
Copy link
Owner Author

Cimbali commented Nov 4, 2021

I checked the sample with the Windows binary of version 1.7b1 and video on page 2 didn’t start automatically (there is no other media in the PDF document).

I guess GStreamer (and its Python bindings) aren’t included in the binary, are they?

It should work regardless of the backend, either VLC or GStreamer. I’m not entirely sure all GStreamer dependencies are shipped properly and that’s one of the things I’m waiting for to make an actual release.

Does the media play at all, e.g. if you click on it? I.e. is auto-play broken or is it playing videos? We probably should take this to a different issue tbh.

@complanar

This comment has been minimized.

@Cimbali

This comment has been minimized.

@complanar

This comment has been minimized.

@Cimbali

This comment has been minimized.

@complanar

This comment has been minimized.

@Cimbali

This comment has been minimized.

@complanar

This comment has been minimized.

Repository owner locked and limited conversation to collaborators Nov 22, 2022
@Cimbali Cimbali converted this issue into a discussion Nov 22, 2022
@Cimbali Cimbali reopened this Nov 22, 2022
@Cimbali
Copy link
Owner Author

Cimbali commented Nov 22, 2022

While looking into #258 I figured out (from this very well sourced post) that our solution for autostart in #71 is incorrect.

The autostart flag exposed in poppler!829 does not mean what we thought it means. From the PDF spec 1.7 (Nov 2006) table 9.15 “Entries in a media play parameters MH/BE dictionary” (p. 770):

A boolean (Optional) If true, the media should automatically play when activated. If false, the media should be initially paused when activated (for example, the first frame is displayed). Relevant only for media that may be paused. Default value: true.

So it’s autostart on activation, not on page entry. What we need is the Additional Actions dictionary that has appeared several times in this conversation already:

From op. cit. Table 8.38 “Additional entries specific to a screen annotation”:

AA dictionary (Optional; PDF 1.2) An additional-actions dictionary defining the screen annotation’s behavior in response to various trigger events (see Section 8.5.2, “Trigger Events”).

And the section in question

8.5.2 Trigger Events

An annotation, page object, or (beginning with PDF 1.3) interactive form field may include an entry named AA that specifies an additional-actions dictionary (PDF 1.2) that extends the set of events that can trigger the execution of an action. In PDF 1.4, the document catalog dictionary (see Section 3.6.1, “Document Catalog”) may also contain an AA entry for trigger events affecting the document as a whole. Tables 8.44 to 8.47 show the contents of this type of dictionary. (See implementation notes 98 and 99 in Appendix H.)

PDF 1.5 introduces four trigger events to support multimedia presentations:

  • The PO and PC entries have a similar function to the O and C entries in the page object’s additional-actions dictionary (see Table 8.45). However, associating
    these triggers with annotations allows annotation objects to be self-contained and greatly simplifies authoring. For example, annotations containing such actions can be copied or moved between pages without requiring page open/close actions to be changed.
  • The PV and PI entries allow a distinction between pages that are open and pages that are visible. At any one time, only a single page is considered open in the viewer application, while more than one page may be visible, depending on the page layout
  • Note: For these trigger events, the values of the flags specified by the annotation’s F entry (see Section 8.4.2, “Annotation Flags”) have no bearing on whether a given trigger event occurs.*

TABLE 8.44 Entries in an annotation’s additional-actions dictionary

KEY TYPE VALUE
[…] […] […]
PO dictionary (Optional; PDF 1.5) An action to be performed when the page containing the annotation is opened (for example, when the user navigates to it from the next or previous page or by means of a link annotation or outline item). The action is executed after the O action in the page’s additional-actions dictionary (see Table 8.45) and the OpenAction entry in the document catalog (see Table 3.25), if such actions are present.
PC dictionary (Optional; PDF 1.5) An action to be performed when the page containing the annotation is closed (for example, when the user navigates to the next or previous page, or follows a link annotation or outline item). The action is executed before the C action in the page’s additional-actions dictionary (see Table 8.45), if present.
[…] […] […]

TABLE 8.45 Entries in a page object’s additional-actions dictionary

KEY TYPE VALUE
O dictionary (Optional; PDF 1.2) An action to be performed when the page is opened (for example, when the user navigates to it from the next or previous page or by means of a link annotation or outline item). This action is independent of any that may be defined by the OpenAction entry in the document catalog (see Section 3.6.1, “Document Catalog”) and is executed after such an action. (See implementation note 100 in Appendix H.)
C dictionary (Optional; PDF 1.2) An action to be performed when the page is closed (for example, when the user navigates to the next or previous page or follows a link annotation or an outline item). This action applies to the page being closed and is executed before any other page is opened. (See implementation note 100 in Appendix H.)
[…] […] […]

@Cimbali
Copy link
Owner Author

Cimbali commented Nov 27, 2022

It appears Okular uses the same interpretation as pympress does currently.

Repository owner unlocked this conversation Dec 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement external dependency Progress on this issue is blocked by a bug or lacking feature in software on which we depend
Projects
None yet
Development

No branches or pull requests

4 participants