java-imp-vplayer.mkiv /size: 3142 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=java-imp-vplayer,
3%D        version=2009.12.31,
4%D          title=\CONTEXT\ JavaScript Macros,
5%D       subtitle=Shockwave Support,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14%D As part of the interaction manual writing this code was moved here. It's
15%D kind of obsolete as shockwave is obsolete. Anywaym, here's how it works.
16%D One can actually set all kind of properties but let's not waste time on
17%D that. Maybe some day \PDF\ will have proper native video support.
18%D
19%D \starttyping
20%D \starttext
21%D
22%D     \useJSscripts[vplayer]
23%D
24%D     \setupinteraction
25%D       [state=start]
26%D
27%D     \externalfigure
28%D       [shockwave]
29%D       [frame=on,
30%D        width=480pt,
31%D        height=270pt,
32%D       %file=mathematics.mp4, % Hollie McNish, Martin Pyper & Jules Buckley (Metropole Orchestra)
33%D        file=bathtub.mp4,     % Jacob Collier & Becca Stevens
34%D        label=foo]
35%D
36%D     \goto{START} [JS(StartShockwave{foo})]
37%D     \goto{REWIND}[JS(RewindShockwave{foo})]
38%D     \goto{PAUSE} [JS(PauseShockwave{foo})]
39%D     \goto{STOP}  [JS(StopShockwave{foo})]
40%D
41%D \stoptext
42%D \stoptyping
43
44% using vplayer9.swf from ctan:
45
46\startluaparameterset[shockwave:display]
47    toolbar  = true,
48 -- preview  = "somefile",
49    open     = "click",
50    close    = "focus",
51\stopluaparameterset
52
53\startJSpreamble shockwave used now
54
55    function StartShockwave(label) {
56        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
57        if (rm.activated) {
58            // ok
59        } else {
60            rm.activated = true ;
61        }
62        rm.callAS("rewind") ;
63        rm.callAS("playPause") ;
64    }
65
66    function StopShockwave(label) {
67        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
68        if (rm.activated) {
69            rm.callAS("pause") ;
70            rm.callAS("rewind") ;
71        }
72    }
73
74    function RewindShockwave(label) {
75        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
76        if (rm.activated) {
77            rm.callAS("rewind") ;
78        }
79    }
80
81    function PauseShockwave(label) {
82        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
83        if (rm.activated) {
84            rm.callAS("playPause") ;
85        }
86    }
87
88\stopJSpreamble
89
90\definereference[StartShockwave] [JS(StartShockwave)]
91\definereference[StopShockwave]  [JS(StopShockwave)]
92\definereference[RewindShockwave][JS(RewindShockwave)]
93\definereference[PauseShockwave] [JS(PauseShockwave)]
94
95\unprotect
96
97\doglobal \useexternalfigure
98  [shockwave]
99  [vplayer9.swf]
100 %[arguments=\luaparameterset{shockwave:arguments}{src="\externalfigureparameter\v!file",source="\externalfigureparameter\v!file"},
101  [\c!arguments=\luaparameterset{shockwave:arguments}{source="\externalfigureparameter\v!file",autoPlay=true},
102   \c!resources=\luaparameterset{shockwave:resources}{files={"\externalfigureparameter\v!file"}},
103   \c!display=shockwave:display]
104
105\protect \endinput
106