--- /home/ousia/Desktop/lpdf-wid.lmt +++ /home/ousia/mkxl/lpdf-wid.lmt @@ -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 @@ -615,7 +619,7 @@ -- sound is different, no window (or zero) so we need to collect them and -- force them if not set -local ms, mu, mf = { }, { }, { } +local mu, mf = { }, { }, { } local function delayed(label) local reserved = mu[label] @@ -623,7 +627,7 @@ reserved = pdfreserveobject() mu[label] = reserved end - return pdfreference(reserved) + return reserved end local function checkedreference(ref) @@ -639,16 +643,16 @@ local openpage = specification.openpage local closepage = specification.closepage local option = settings_to_hash(specification.option) - if option[v_auto] then - if not openpage or openpage == "" then - openpage = variables.StartCurrentRendering - end - if not closepage or closepage == "" then - closepage = variables.StopCurrentRendering - end - end openpage = checkedreference(openpage) closepage = checkedreference(closepage) + if option[v_auto] then + if not openpage then + openpage = executers.startrendering(label) + end + if not closepage then + closepage = executers.stoprendering(label) + end + end if openpage or closepage then actions = pdfdictionary { PO = openpage, @@ -656,13 +660,8 @@ } end local page = tonumber(specification.page) or texgetcount("realpageno") -- todo - local r = mu[label] or pdfreserveobject() -- reserve, child refers to parent - local a = pdfdictionary { - S = pdfconstant("Rendition"), - R = mf[label], - OP = 0, - AN = pdfreference(r), - } + local r = delayed(label) -- reserve, child refers to parent + local a = executers.startrendering(label) local bs, bc = pdfborder() local d = pdfdictionary { Subtype = pdfconstant("Screen"), @@ -676,7 +675,6 @@ local width = specification.width or 0 local height = specification.height or 0 context(nodeinjections.annotation(width,height,0,d(),r)) -- save ref - return pdfreference(r) end -- some dictionaries can have a MH (must honor) or BE (best effort) capsule @@ -713,7 +711,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 +731,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 +752,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 @@ -780,21 +794,17 @@ function codeinjections.insertrenderingwindow(specification) local label = specification.label codeinjections.processrendering(label) - ms[label] = insertrenderingwindow(specification) + insertrenderingwindow(specification) end local function set(operation,label) - if not label or label == "" then - -- This one is local to the window so unlikely to be set. - label = getmacro("currentrendering") - end if label and label ~= "" then codeinjections.processrendering(label) return pdfdictionary { S = pdfconstant("Rendition"), OP = operation, R = mf[label], - AN = ms[label] or delayed(label), + AN = pdfreference(delayed(label)), } end end