1if not modules then modules = { } end modules ['lpdf-mov'] = {
2 version = 1.001,
3 comment = "companion to lpdf-ini.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local format = string.format
10
11local lpdf = lpdf
12local context = context
13
14local nodeinjections = backends.pdf.nodeinjections
15local pdfconstant = lpdf.constant
16local pdfdictionary = lpdf.dictionary
17local pdfarray = lpdf.array
18local pdfborder = lpdf.border
19
20
21
22
23function nodeinjections.insertmovie(specification)
24
25 local width = specification.width
26 local height = specification.height
27 local factor = specification.factor or number.dimenfactors.bp
28 local moviedict = pdfdictionary {
29 F = specification.foundname or specification.file,
30 Aspect = pdfarray { factor * width, factor * height },
31 Poster = (specification.preview and true) or false,
32 }
33 local controldict = pdfdictionary {
34 ShowControls = (specification.controls and true) or false,
35 Mode = (specification["repeat"] and pdfconstant("Repeat")) or nil,
36 }
37 local bs, bc = pdfborder()
38 local action = pdfdictionary {
39 Subtype = pdfconstant("Movie"),
40 Border = bs,
41 C = bc,
42 T = format("movie %s",specification.tag or specification.label),
43 Movie = moviedict,
44 A = controldict,
45 }
46 context(nodeinjections.annotation(width,height,0,action()))
47end
48
49function nodeinjections.insertsound(specification)
50 local controldict = nil
51 if specification["repeat"] then
52 controldict = pdfdictionary {
53 Mode = pdfconstant("Repeat")
54 }
55 end
56 local sounddict = pdfdictionary {
57 F = specification.foundname or specification.file
58 }
59 local bs, bc = pdfborder()
60 local action = pdfdictionary {
61 Subtype = pdfconstant("Movie"),
62 Border = bs,
63 C = bc,
64 T = format("sound %s",specification.tag or specification.label),
65 Movie = sounddict,
66 A = controldict,
67 }
68 context(nodeinjections.annotation(0,0,0,action()))
69end
70 |