0

last year I added soundtrack and a kind of "laser pointer" (synchronized with the sound) to my lectures. I’m using beamer slides, a lot of pstricks and always the Latex->dvips->ps2pdf workflow. The "laser pointer" is realized with a "Circle-annotation" (with opacity 0.5) in pdf.

Therefore, I wrote a command \plusaudio which takes the mp3 filename as first argument and the timing and position data of the "laser pointer" as second argument, e.g.:

\plusaudio{Kapitel1_NT_0003_einf01_1}{[[0],[7034,[137,243,172,208]],[10118,[302,242,337,207]],[10119],…}

(here the annotation is visible from 7034ms to 10118ms, the bounding box of the annotation is moved from [137,243,172,208] to [302,242,337,207], at 10119ms the annotation is switched to invisible)

The first argument (mp3-File) was passed to \includemedia from media9 package, the second argument (time and position data) was passed to a "Widget Annotation" with a page-open javascript, which results in setting a jacascript Variable "LPTimingArray" containing the time and position data.

The rest of the programming was done in the javascript-side of the pdf:

  • start an interval timer every 100ms
  • use the callAS("currentTime") method to get the current time of the media playback
  • search the LPTimingArray if and where the circle annotation is visible/invisble

By means of the callAs-function (javascript-side of the pdf) the synchronization from sound and "laser pointer" is always guaranteed and I added a pause/play, fast forward and fast backward button.

As flash is switched off in 2021 this method is no longer working. I found an alternative way to embed and play the sound (see my post in Media9 is becoming obsolete Dec 2020. Any alternatives for embedding video/audio in LaTeX?). The sound is controlled by a "media rendition".

For my "laser pointer" feature all of the control resides in the javascript area of the pdf. Play/pause, rewind and fast forward buttons are realized by mediaplayer methods play, pause and seek (see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf, page 505). In Windows this is working fine with "vnd.adobe.swname:MSFT_WindowsMediaPlayer", but seek is not working with "vnd.adobe.swname:ADBE_MCI". However, one problem remains:

To have access to the media renditions in javascript, there has to be a "/Renditions" name tree entry in the catalog "/Names" dictionary of the pdf-File. I get this done by

\special{ps:: SDict~begin~[~{Catalog}~<</Names~<</Renditions~\pbs_pdflastobj:>>~>>~/PUT~pdfmark~end}

(\pbs_pdflastobj: is the array of rendition name tree).

Using this method all of the media and "laser pointer" control is working fine, but (and that is the remaining problem) the "/Dests" name tree is missing and none of the links to destinations in the document is working anymore. Dropping this line of code, the "/Dests" name tree is inserted, but no name tree for the "/Renditions" (and therefore my control of the media by javascript is not working). This is the case with "Acrobat Distiller" as well as with "ps2pdf".

I found a workaround, but there should be a way to simplify the process. In my workaround I don’t insert the rendition name tree in postscript (dropping the line of code above), but

1.) use "Acrobat Distiller" to produce a first version of the pdf ("/Dests" name tree is included)

2.) use "qpdf" with "--object-streams=disable" for an almost ASCII version of the pdf

3.) extend this ASCII pdf with the "/Renditions" name tree (and update the xref table) by a self-written c-program

4.) use again "qpdf" with "--compress-streams=y" to get a pdf of comparable file size as the one of the first step

Does anyone has an idea to solve this problem?

Regards, Fritz

Edit: here is a screenshot showing the properties of the the rendition in Acrobat XI when no name tree is inserted enter image description here

Fritz
  • 307
  • try to make a small complete example which demonstrates how the Dests are getting lost. – Ulrike Fischer Apr 14 '21 at 11:13
  • I tried a bit, the dest tree is not lost for me, but I get two /Names entries with dictionary values in the catalog, there are not combined by ps2pdf, and so the reader will ignore one of them. I don't see anything in the pdfmark reference that looks as if one can use it to add something to the /Names dictionary. – Ulrike Fischer Apr 14 '21 at 14:47
  • Thanks for your comment. The problem is on "postcript-side". Is it possible to share a postscript file? – Fritz Apr 15 '21 at 08:00
  • yes I think so. You could ask on the gs-devel list, if there is some postscript code that would allow to add a name tree. – Ulrike Fischer Apr 15 '21 at 08:05
  • Thanks, I will try this – Fritz Apr 15 '21 at 08:40
  • Do you use this.media.getRendition("<Media>") to access a Rendition object? Does it require the Rendition to be mapped in the Name tree? What about accessing the Rendition via a unique name given as /N (<my Rendiion name>) in the Rendition dictionary? Acc. to the PDF spec 1.7, page 759, a Rendition dictionary is not required to have a name tree entry. – AlexG Apr 15 '21 at 13:43
  • Yes, I use app.doc.media.getRendition("name") to find the rendition with /N ("name") set in the media rendition dictionary (subtype /S /MR). Without the rendition name tree the mp3 runs only once and there is an error message (invalid arguments) when I call app.doc.media.getRendition("name") a second time. I added a screenshot of the rendition properties in Acrobat XI. The checkbox "allow access to javascript" is checked with rendition name tree and unchecked without. If you have access you can take a look to the files at https://bugs.ghostscript.com/show_bug.cgi?id=703787 – Fritz Apr 15 '21 at 16:23

0 Answers0