summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/java-imp-vplayer.mkiv
blob: 4ed08cad60f51598cc8ff4e6cf95d0d4321f3216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
%D \module
%D   [       file=java-imp-vplayer,
%D        version=2009.12.31,
%D          title=\CONTEXT\ JavaScript Macros,
%D       subtitle=Shockwave Support,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D As part of the interaction manual writing this code was moved here. It's
%D kind of obsolete as shockwave is obsolete. Anywaym, here's how it works.
%D One can actually set all kind of properties but let's not waste time on
%D that. Maybe some day \PDF\ will have proper native video support.
%D
%D \starttyping
%D \starttext
%D
%D     \useJSscripts[vplayer]
%D
%D     \setupinteraction
%D       [state=start]
%D
%D     \externalfigure
%D       [shockwave]
%D       [frame=on,
%D        width=480pt,
%D        height=270pt,
%D       %file=mathematics.mp4, % Hollie McNish, Martin Pyper & Jules Buckley (Metropole Orchestra)
%D        file=bathtub.mp4,     % Jacob Collier & Becca Stevens
%D        label=foo]
%D
%D     \goto{START} [JS(StartShockwave{foo})]
%D     \goto{REWIND}[JS(RewindShockwave{foo})]
%D     \goto{PAUSE} [JS(PauseShockwave{foo})]
%D     \goto{STOP}  [JS(StopShockwave{foo})]
%D
%D \stoptext
%D \stoptyping

% using vplayer9.swf from ctan:

\startluaparameterset[shockwave:display]
    toolbar  = true,
 -- preview  = "somefile",
    open     = "click",
    close    = "focus",
\stopluaparameterset

\startJSpreamble shockwave used now

    function StartShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            // ok
        } else {
            rm.activated = true ;
        }
        rm.callAS("rewind") ;
        rm.callAS("playPause") ;
    }

    function StopShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            rm.callAS("pause") ;
            rm.callAS("rewind") ;
        }
    }

    function RewindShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            rm.callAS("rewind") ;
        }
    }

    function PauseShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            rm.callAS("playPause") ;
        }
    }

\stopJSpreamble

\definereference[StartShockwave] [JS(StartShockwave)]
\definereference[StopShockwave]  [JS(StopShockwave)]
\definereference[RewindShockwave][JS(RewindShockwave)]
\definereference[PauseShockwave] [JS(PauseShockwave)]

\unprotect

\doglobal \useexternalfigure
  [shockwave]
  [vplayer9.swf]
 %[arguments=\luaparameterset{shockwave:arguments}{src="\externalfigureparameter\v!file",source="\externalfigureparameter\v!file"},
  [\c!arguments=\luaparameterset{shockwave:arguments}{source="\externalfigureparameter\v!file",autoPlay=true},
   \c!resources=\luaparameterset{shockwave:resources}{files={"\externalfigureparameter\v!file"}},
   \c!display=shockwave:display]

\protect \endinput