lpdf-mov.lua /size: 2553 b    last modification: 2020-07-01 14:35
1
if
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 9
local
format
=
string
.
format
10 11
local
lpdf
=
lpdf
12
local
context
=
context
13 14
local
nodeinjections
=
backends
.
pdf
.
nodeinjections
15
local
pdfconstant
=
lpdf
.
constant
16
local
pdfdictionary
=
lpdf
.
dictionary
17
local
pdfarray
=
lpdf
.
array
18
local
pdfborder
=
lpdf
.
border
19
local
write_node
=
node
.
write
20 21
function
nodeinjections
.
insertmovie
(
specification
)
22
-- managed in figure inclusion: width, height, factor, repeat, controls, preview, label, foundname
23
local
width
=
specification
.
width
24
local
height
=
specification
.
height
25
local
factor
=
specification
.
factor
or
number
.
dimenfactors
.
bp
26
local
moviedict
=
pdfdictionary
{
27
F
=
specification
.
foundname
,
28
Aspect
=
pdfarray
{
factor
*
width
,
factor
*
height
}
,
29
Poster
=
(
specification
.
preview
and
true
)
or
false
,
30
}
31
local
controldict
=
pdfdictionary
{
32
ShowControls
=
(
specification
.
controls
and
true
)
or
false
,
33
Mode
=
(
specification
[
"
repeat
"
]
and
pdfconstant
(
"
Repeat
"
)
)
or
nil
,
34
}
35
local
bs
,
bc
=
pdfborder
(
)
36
local
action
=
pdfdictionary
{
37
Subtype
=
pdfconstant
(
"
Movie
"
)
,
38
Border
=
bs
,
39
C
=
bc
,
40
T
=
format
(
"
movie %s
"
,
specification
.
label
)
,
41
Movie
=
moviedict
,
42
A
=
controldict
,
43
}
44
write_node
(
nodeinjections
.
annotation
(
width
,
height
,
0
,
action
(
)
)
)
-- test: context(...)
45
end
46 47
function
nodeinjections
.
insertsound
(
specification
)
48
-- managed in interaction: repeat, label, foundname
49
local
soundclip
=
interactions
.
soundclips
.
soundclip
(
specification
.
label
)
50
if
soundclip
then
51
local
controldict
=
pdfdictionary
{
52
Mode
=
(
specification
[
"
repeat
"
]
and
pdfconstant
(
"
Repeat
"
)
)
or
nil
53
}
54
local
sounddict
=
pdfdictionary
{
55
F
=
soundclip
.
filename
56
}
57
local
bs
,
bc
=
pdfborder
(
)
58
local
action
=
pdfdictionary
{
59
Subtype
=
pdfconstant
(
"
Movie
"
)
,
60
Border
=
bs
,
61
C
=
bc
,
62
T
=
format
(
"
sound %s
"
,
specification
.
label
)
,
63
Movie
=
sounddict
,
64
A
=
controldict
,
65
}
66
write_node
(
nodeinjections
.
annotation
(
0
,
0
,
0
,
action
(
)
)
)
-- test: context(...)
67
end
68
end
69