Hi Hans,

Michal Vlasák send me the attached patch to be able to set volume,
opacity and repeat for renditions, such as in:

  \setupinteraction[state=start]
  \starttext
  \null\page
  \definerenderingwindow[myrenderingwindow]
    [width=\textwidth, height=\textwidth,
     openpageaction=StartRendering{\currentrendering},
     closepageaction=StopRendering{\currentrendering}]
  \startTEXpage[offset=1ex, pagestate=start]
  \userendering[key-name][video/mp4][video.mp4]
    [embed=yes, volume=25]
  \placerenderingwindow[myrenderingwindow][key-name]
  \stopTEXpage
  \null\page
  \stoptext

He asked me to submit the patch to ConTeXt to be merged, since he lacks
the free time to submit it himself.

Many thanks for your help,

Pablo
diff -u ~/current/lpdf-wid.lmt ~/mvlasak/lpdf-wid.lmt
--- ~/current/lpdf-wid.lmt	2022-12-29 19:10:22.651851689 +0100
+++ ~/mvlasak/lpdf-wid.lmt	2022-12-29 18:10:08.334122418 +0100
@@ -64,6 +64,10 @@
 local v_compress               = variables.compress
 local v_list                   = variables.list
 local v_title                  = variables.title
+local v_controls               = variables.controls
+local v_volume                 = variables.volume
+local v_repeat                 = variables["repeat"]
+local v_opacity                = variables.opacity
 
 local lpdf                     = lpdf
 
@@ -713,7 +717,7 @@
          --          B = start,
          --     }
          -- }
-            local parameters = pdfdictionary {
+            local permissions = pdfdictionary {
                 Type = pdfconstant("MediaPermissions"),
                 TF   = pdfstring("TEMPALWAYS"), -- TEMPNEVER TEMPEXTRACT TEMPACCESS TEMPALWAYS / needed for acrobat/wmp
             }
@@ -733,6 +737,20 @@
                     forcereference = option[v_list] ~= v_no,
                 }
             end
+            local media_play_params = pdfdictionary {
+                Type = pdfconstant("MediaPlayParams"),
+                BE   = pdfdictionary {
+                    C  = option[v_controls] and option[v_controls] ~= v_no or false,
+                    V  = tonumber(option[v_volume]) or 100,
+                    RC = tonumber(option[v_repeat]) or 1,
+                },
+            }
+            local media_screen_params = pdfdictionary {
+                Type = pdfconstant("MediaScreenParams"),
+                BE   = pdfdictionary {
+                    O = tonumber(option[v_opacity]) or 1.0,
+                },
+            }
             local clip = pdfdictionary {
                 Type = pdfconstant("MediaClip"),
                 S    = pdfconstant("MCD"),
@@ -740,13 +758,15 @@
                 CT   = mimetype,
                 Alt  = pdfarray { "", "file not found" }, -- language id + message
                 D    = descriptor,
-                P    = pdfreference(pdfflushobject(parameters)),
+                P    = pdfreference(pdfflushobject(permissions)),
             }
             local rendition = pdfdictionary {
                 Type = pdfconstant("Rendition"),
                 S    = pdfconstant("MR"),
                 N    = pdfunicode(label),
                 C    = pdfreference(pdfflushobject(clip)),
+                P    = media_play_params,
+                SP   = media_screen_params,
             }
             mf[label] = pdfreference(pdfflushobject(rendition))
         end
diff -u ~/current/mult-def.lua ~/mvlasak/mult-def.lua
--- ~/current/mult-def.lua	2022-12-29 19:11:51.929604907 +0100
+++ ~/mvlasak/mult-def.lua	2022-12-28 18:43:16.207399177 +0100
@@ -10634,6 +10634,9 @@
    ["pe"]="آفست",
    ["ro"]="offset",
   },
+  ["opacity"]={
+   ["en"]="opacity",
+  },
   ["openaction"]={
    ["cs"]="otevriakci",
    ["de"]="oeffenaktion",
@@ -19481,6 +19484,9 @@
    ["en"]="vfenced",
    ["fr"]="cloturev",
   },
+  ["volume"]={
+   ["en"]="volume",
+  },
   ["vulgarfraction"]={
    ["en"]="vulgarfraction",
    ["fr"]="vulgarfraction",
_______________________________________________
dev-context mailing list
dev-context@ntg.nl
https://mailman.ntg.nl/mailman/listinfo/dev-context

Reply via email to