More context is in previous messages, but here is the patch for ConTeXt
to make scripting multimedia possible:

    --- a/tex/context/base/mkxl/lpdf-wid.lmt
    +++ b/tex/context/base/mkxl/lpdf-wid.lmt
    @@ -649,6 +649,7 @@ local function insertrenderingwindow(specification)
             Subtype = pdfconstant("Screen"),
             P       = pdfreference(pdfpagereference(page)),
             A       = a, -- needed in order to make the annotation clickable 
(i.e. don't bark)
    +        T       = pdfunicode(label), -- title (for JS)
             Border  = bs,
             C       = bc,
             AA      = actions,
    @@ -693,7 +694,7 @@ local function insertrendering(specification)
          --     }
          -- }
             local parameters = pdfdictionary {
    -            Type = pdfconstant(MediaPermissions),
    +            Type = pdfconstant("MediaPermissions"),
                 TF   = pdfstring("TEMPALWAYS"), -- TEMPNEVER TEMPEXTRACT 
TEMPACCESS TEMPALWAYS / needed for acrobat/wmp
             }
             local descriptor = pdfdictionary {
    @@ -723,7 +724,7 @@ local function insertrendering(specification)
             local rendition = pdfdictionary {
                 Type = pdfconstant("Rendition"),
                 S    = pdfconstant("MR"),
    -            N    = label,
    +            N    = pdfunicode(label),
                 C    = pdfreference(pdfflushobject(clip)),
             }
             mf[label] = pdfreference(pdfflushobject(rendition))
    @@ -761,6 +762,20 @@ function codeinjections.processrendering(label)
         end
     end
    
    +-- needed mapping for access from JS
    +local function flushrenderings()
    +    if next(mf) then
    +        local r = pdfarray()
    +        for label, reference in sortedhash(mf) do
    +            r[#r+1] = pdfunicode(label)
    +            r[#r+1] = reference -- already a reference
    +        end
    +        
lpdf.addtonames("Renditions",pdfreference(pdfflushobject(pdfdictionary{ Names = 
r })))
    +    end
    +end
    +
    +lpdf.registerdocumentfinalizer(flushrenderings,"renderings")
    +
     function codeinjections.insertrenderingwindow(specification)
         local label = specification.label
         codeinjections.processrendering(label)

The patch is also be available here
https://github.com/vlasakm/context-mirror/commit/99f81beae0d13f1aecc20be187ada9eb88a2aa68
until it is applied (for full file download, which is available under
the three dots next to the file name).

The created Screen annotation will be given the title, that corresponds
to the second \placerenderingwindow parameter. So here:

    \definerenderingwindow[soundplace]
      [width=0pt, height=0pt]
    
    \useexternalrendering[mainsound][audio/mp3][sound.mp3][embed=yes]
    
    \placerenderingwindow[soundplace][mainsound]

both the screen annotation and rendition are available under the name
"mainsound". The name "soundplace" can be anything (even "mainsound"),
it doesn't propagate to the PDF file in any way.

And here is the patch required to make Pablo's example work:

    --- a/pablo.tex
    +++ b/pablo.tex
    @@ -7,8 +7,10 @@
     function GoToFirstSlide(label) {
     this.pageNum = 0 ;
     var rendition = this.media.getRendition(label) ;
    +var screen = this.media.getAnnot({nPage: 0, cAnnotTitle: label}) ;
     var player = app.media.openPlayer({
         rendition: rendition,
    +    annot: screen,
       });
     }

The second possibility I proposed previously is not as general, and
implementing it is not worth, until it is really needed (which I presume
won't happen).

Michal Vlasák
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to