summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/back-swf.mkiv
blob: 0a53a8fd2e7a5d2a7ec75555cb77b7525a59e1a8 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
%D \module
%D   [       file=back-swf,
%D        version=2009.12.31,
%D          title=\CONTEXT\ Backend Macros,
%D       subtitle=Shockwave Experiment,
%D         author=Hans Hagen \& Luigi Scarso,
%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 This is only a placeholder that demonstrates the usage of swf resources.
%D There is no need to include this file into the format. The module was
%D tested by Luigi and Willi and based on their suggestions the functionality
%D was improved.
%D
%D \starttyping
%D \enabletrackers[graphics.locating]
%D \enabletrackers[backend.swf]
%D
%D \startluaparameterset [swf:relative:resources]
%D     relativepaths = {
%D         "assets"
%D     }
%D \stopluaparameterset
%D
%D \startluaparameterset[swf:relative:display]
%D     toolbar  = true,
%D     preview  = "images/posterframes/*.jpg", -- relative to assets
%D     open     = "click",
%D     close    = "focus",
%D \stopluaparameterset
%D
%D \startTEXpage
%D    \externalfigure
%D      [whatever.swf]
%D      [resources=swf:relative:resources,
%D       display=swf:relative:display]
%D \stopTEXpage
%D \stoptyping

%D Embedding (and using) movies used to be a breeze in acrobat but depended
%D on a plugin. Then we got renditions that depended on the built-in flash
%D player. And now we have rich media, depending on whatever and being able
%D to use the flash player as well ... but it's an erratic and soon obsolete
%D adventure. So \unknown\ we do provide the user the means but stay away
%D from it ourselves: it's a dead end. The following tricks use the already
%D present shockwave (flash) trickery.
%D
%D At some point we will no longer provide this in the core but load it at
%D runtime.
%D
%D \starttyping
%D \externalfigure
%D   [shockwave]
%D   [file=test.mp4,
%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 \useexternalrendering[foo][application/x-shockwave-flash][test.swf][embed=yes,width=100pt,height=100pt]
%D \definerenderingwindow[foo][width=100pt,height=100pt]
%D
%D \placerenderingwindow[foo][foo]
%D
%D \goto{START}[StartRendering{foo}]
%D \goto{STOP} [StopRendering{foo}]
%D \goto{PAUSE}[PauseRendering{foo}]
%D
%D %     \useexternalrendering[foo][audio/mpeg][t:/sources/akkerman.mp3][embed=yes]
%D %     \definerenderingwindow[foo][width=0pt,height=0pt]
%D %   % \placerenderingwindow[foo][foo]
%D %     \setupbackgrounds[page][background=resources]
%D %     \setlayer[resources]{\placerenderingwindow[foo][foo]}
%D %     \goto{START}[StartRendering{foo}]
%D %     \goto{STOP} [StopRendering{foo}]
%D %     \goto{PAUSE}[PauseRendering{foo}]
%D \stoptyping

\unprotect

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

% using vplayer9.swf from ctan:

\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]

\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

% using videoplayer.swf from adobe or strobemediaplayback.swf from sourceforge:

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

\startJSpreamble shockwave used now
    function StartShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            rm.callAS("multimedia_play") ;
        } else {
            rm.activated = true ;
        }
    }
    function StopShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            rm.callAS("multimedia_pause") ;
            rm.callAS("multimedia_rewind") ;
        }
    }
    function RewindShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            rm.callAS("multimedia_rewind") ;
        }
    }
    function PauseShockwave(label) {
        var rm = this.getAnnotsRichMedia(this.pageNum,label)[0] ;
        if (rm.activated) {
            rm.callAS("multimedia_pause") ;
        }
    }
\stopJSpreamble

% \useexternalfigure
%   [shockwave]
%   [strobemediaplayback.swf]
%   [arguments=\luaparameterset{shockwave:arguments}{src="\externalfigureparameter\v!file"},
%    resources=\luaparameterset{shockwave:resources}{files={"\externalfigureparameter\v!file"}},
%    display=shockwave:display]

\protect \endinput

\starttext

\startluaparameterset [swf:myset:display:1]
    toolbar  = true,
    preview  = "assets/images/posterframes/SPT_14-16_Ra_01_PN_LE01_02_DoLikeMeLater_posterframe.jpg",
 -- preview  = "t:/sources/cow.pdf",
 -- preview  = "t:/sources/hacker.jpg",
    open     = "click", -- click page focus
    close    = "focus", -- click page focus
\stopluaparameterset

\startluaparameterset [swf:myset:resources:1]
    paths = {
        "assets"
    },
    files = {
        -- "somename_1"
        -- "somename_1"
    }
\stopluaparameterset

\startluaparameterset [swf:dolikemelater:resources]
    paths    = {
        "assets"
    },
\stopluaparameterset

% preview=swf:myset:display:1
% controls=swf:myset:controls:1
% resources=swf:myset:resources:1

\placefigure
  {flash demo}
  {\startcombination[2*2]
     {\externalfigure[trasf1.swf][width=0.45\textwidth,height=0.25\textheight]} {one}
     {\externalfigure[trasf2.swf][width=0.45\textwidth,height=0.25\textheight]} {two}
     {\externalfigure[trasf3.swf][width=0.45\textwidth,height=0.25\textheight]} {three}
     {\externalfigure[trasf4.swf][width=0.45\textwidth,height=0.25\textheight]} {four}
   \stopcombination}

\stoptext