summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/flashmovie/flashmovie.sty
blob: 051b5971da1f134deeae4245381b572f39fd8f35 (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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
%%%%%%%%%%%%% flashmovie.sty
%%%%%%%%%%%%% Copyright 2010 Timo Hartmann (thartmann15 at googlemail.com)
%
% Version 0.2
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This license applies to following files:
%   flashmovie.sty,test.tex,test-flv.tex,README
%
%
%
% The file "player_flv_maxi.swf" is NOT from me. This is the original flv-player 
% from http://flv-player.net whose developer is neolao. 
% This file is distributed under the MPL-license. See the directory 
% "flv-player-license" for more information. The file "license.txt" in that directory
% is from the original source-code of the flv-player. A copy of the MPL-license is also
% included there.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% special thanks to following people for providing support, tips and improvements:
%  - Elie Roux
%  - Marco Aurélio Graciotto Silva
%  - neolao
%
% changelog:
%   0.2 : 2010-04-21 : major overhaul: keyval 'engine', flv-player-engine,...
%   0.1 : 2010-04-13 : a bunch of bugfixes
%   0.0 : 2009-12-06 : initial release
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% This package allows direct embedding of flash movies into PDF files. It is
% designed for use with pdflatex.
%
% Basically it uses the fact that the Adobe Reader 9 contains an embedded Adobe Flash 
% player which can be invoked with the "rich media annotation" feature which is described 
% in "Adobe Supplement to the ISO 32000 BaseVersion: 1.7 ExtensionLevel: 3".
%
% advantages:
%   - You can directly embed videos into the pdf (external window is optimal and not necessary).
%   - You can play back videos without worrying about platform dependencies.
%
% disadvantages:
%   - You can only play back embedded videos with Adobe Reader 9 and upwards.
%
% usage:
%   There are two fundamental different ways to embed videos via the
%   flash-component of the Adobe Reader:
%     - One can create a ".swf"-file and insert this directly
%       into the pdf. See example (1) below.
%     - One can create a ".mp4"-file and use that file as an input
%       to a flash-video-player which renders the videos.
%       Both files (the video and the flash-video-player) will be
%       embedded into the pdf. See example(2) below.
%       Different video formats (mp4/flv/whatever-the-flash-video-player-accepts/...)
%       can be used. Controls are available (depends on the player).
%       See example (2) below.
%
% flash-video-players:
%   There are several flash-video-players available which fit the needs
%   of flashmovie.sty. The different players can be selected with the key "engine",
%   for example: "\flashmovie[width=10cm,height=10cm,engine=flv-player]{saturn5.mp4}".
%
%   The use of "engine=flv-player" is recommended, because it is supported best and
%   the flv-player is included in this distribution.
%
%   List of flash-video-players:
%    - "engine=flv-player". This is an open-source player from http://flv-player.net.
%      It is included with this distribution (the file player_flv_maxi.swf).
%      The developer is neolao. See the directory flv-player-license for the license of it.
%      This is the player which flashmovie.sty supports best.
%
%      supported parameters:
%        auto=0                   --> auto-play off (default)
%        auto=1                   --> auto-play on
%        image=some.jpeg          --> start-image (not necessary)
%
%    - "engine=acropro". This is an commercial player which is distributed with
%      Acrobat 9 Pro. You have to obtain VideoPlayer.swf and SkinOverPlaySeekStop.swf 
%      from Acrobat 9 Pro and put them into the working directory in order to use that module.
%      It is NOT included in this distribution.
%      For this player flashmovie.sty only provides rudimentary support.
%    - "engine=jw-player". This is the JW player from http://www.longtailvideo.com/players/jw-flv-player.
%      You have to obtain player.swf from that site and put it in the working directory in order
%      to use this module.
%      It is NOT included with this distribution.
%      For this player flashmovie.sty only provides rudimentary support.
%    - "engine=osplayer". This is an open-source player from http://www.osflv.com
%      You have to obtain OSplayer.swf from that site and put it in the working directory in order
%      to use this module.
%      It is NOT included with this distribution.
%      For this player flashmovie.sty only provides rudimentary support.
%
%
% example (1)
%   - download a video file to use, for example
%        http://heasarc.gsfc.nasa.gov/Videos/historical/saturn5.avi
%   - transform this video into the flash format with ffmpeg:
%        ffmpeg -i saturn5.avi saturn5.swf
%     (or use any other program capable of this, for example mencoder)
%   - put following line into your tex-file:
%        \flashmovie[width=10cm,height=10cm]{saturn5.swf}
%     (both width and height are needed!)
%   - translate with pdflatex
%   - advantages:
%     - easy
%     - does not rely on external components
%   - disadvantages:
%     - ffmpeg is incapable of embedding h.264 into swf-files, so one can only 
%       use inferior video codecs (sorenson h.263 aka flv,...).
%     - no controls (play,pause,stop,seek,...) possible
%
% example (2)
%   - download a video file to use, for example
%        http://heasarc.gsfc.nasa.gov/Videos/historical/saturn5.avi
%   - transform this video into the mp4 format with ffmpeg:
%        ffmpeg -i saturn5.avi -vcodec libx264 -vpre hq -crf 22 -acodec libfaac -ab 128k -ac 2 saturn5.mp4
%     (or use any other program capable of this, for example mencoder)
%   - alternatively the flv-format with video-codec sorenson h.263 (aka flv) and audio-codec mp3 is also possible:
%       mencoder saturn5.avi -o saturn5.flv -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=300:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050 -ofps 24 -vf harddup -oac mp3lame -lameopts abr:br=56 )
%     (or use ffmpeg to do the same thing...)
%   - put following line into your tex-file:
%        \flashmovie[width=10cm,height=10cm,engine=flv-player,auto=1]{saturn5.mp4}
%     (both width and height are needed! instead of saturn5.mp4 one can also use saturn5.flv but not saturn5.swf)
%   - translate with pdflatex
%   - advantages:
%     - controls (play,pause,stop,seek,...) possible
%     - superior video codec possible (h.264)
%     - one can directly embed mp4 and flv files without conversion
%
% todo:
%   - make more options of rich-media annotations usable, for example activation by clicking, play-count,...
%
% warning:
%   - Because the file names of the movies are directly embedded into the PDFs please use only
%     "normal" file names. More specific use only names compatible with internal PDF strings.
%     There is even a specification what conforming file names are (see the PDF reference).

\RequirePackage{keyval}
\RequirePackage{ifthen}

\ifnum\pdfminorversion<7 \pdfminorversion=7\fi

\def\flashmovieempty{}
\def\flashmoviezero{0}
\def\flashmovieembedded{}

\def\flashmovieparamsclear{
  \def\flashmoviewidth {4cm}
  \def\flashmovieheight{4cm}
  \def\flashmovieimage{}
  \def\flashmovieauto{0}
  \def\flashmovieengine{}
}

\define@key{flashmovieparams}{width}      {\def\flashmoviewidth  {#1}}
\define@key{flashmovieparams}{height}     {\def\flashmovieheight {#1}}
\define@key{flashmovieparams}{image}      {\def\flashmovieimage  {#1}}
\define@key{flashmovieparams}{auto}       {\def\flashmovieauto   {#1}}
\define@key{flashmovieparams}{engine}     {\def\flashmovieengine {#1}}

\newlength{\flashmovie@width}
\newlength{\flashmovie@height}
\newsavebox{\flashmovie@content}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%% variable module %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \flashmovieset{a}{b}   is equivalent to \def\a{b}
% \flashmovieget{a}      is equivalent to \a if a is defined and otherwise it is empty
%
% example:
%   \flashmovieset{aaa}{bla} \flashmovieget{aaa}     ------> produces bla
%                            \flashmovieget{bbb}     ------> produces nothing if bbb is not defined

\def\flashmovieset#1#2{{\expandafter\xdef\csname flashmovie@f@#1\endcsname{#2}}}

% warning: command must be on one line so that there are no spaces generated !
\def\flashmovieget#1{\expandafter\ifx\csname flashmovie@f@#1\endcsname\relax\expandafter\flashmovieempty\else\csname flashmovie@f@#1\endcsname\fi}

%simpler:
%  \def\flashmovieset#1#2{{\expandafter\xdef\csname#1\endcsname{#2}}}
%  \def\flashmovieget#1{\expandafter\ifx\csname#1\endcsname\relax\expandafter\flashmovieempty\else\csname#1\endcsname\fi}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%% file embedding module %%%%%%%%%%%%%%%%%%%%%%%%
%
% usage:
%    \flashmovieembedfile{somefile}
%    \edef\flashmovie@e@somefile{\flashmovieembedded}

\def\flashmovieembedfileinternal#1{
  \immediate
  \pdfobj stream
     attr {  /Type/EmbeddedFile  }
     file {#1}
  \immediate
  \pdfobj { << 
      /Type /Filespec
      /F  (#1)
      /UF (#1)
      /EF << /F \the\pdflastobj\space 0 R >>
    >>}
}

\def\flashmovieembedfile#1{
  \ifthenelse{\equal{\flashmovieget{\pdfmdfivesum file {#1}}}{\flashmovieempty}}{
    \flashmovieembedfileinternal{#1}
    \def\flashmovieembedded{\the\pdflastobj}
    \flashmovieset{\pdfmdfivesum file {#1}}{\flashmovieembedded}
  }{
    \def\flashmovieembedded{\flashmovieget{\pdfmdfivesum file {#1}}}
  }
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\flashmovie{\@ifnextchar[\@flashmovie{\@flashmovie[]}}

\def\@flashmovie[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \ifx\flashmovieimage\flashmovieengine
    \flashmovie@pureswf[#1]{#2}
  \else

    \ifthenelse{\equal{\flashmovieengine}{pure-swf}}
    {\flashmovie@puresef[#1]{#2}}{}

    \ifthenelse{\equal{\flashmovieengine}{flv-player}}
    {\flashmovie@flvplayer[#1]{#2}}{}

    \ifthenelse{\equal{\flashmovieengine}{acropro}}
    {\flashmovie@acropro[#1]{#2}}{}

    \ifthenelse{\equal{\flashmovieengine}{jw-player}}
    {\flashmovie@jwplayer[#1]{#2}}{}

    \ifthenelse{\equal{\flashmovieengine}{osplayer}}
    {\flashmovie@osplayer[#1]{#2}}{}

  \fi
}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% pure swf

\def\flashmovie@pureswf{\@ifnextchar[\@flashmovie@pureswf{\@flashmovie@pureswf[]}}

\def\@flashmovie@pureswf[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \newcount\configurationnum
  \newcount\contentnum
  \newcount\settingsnum

  \flashmovieembedfile{#2}
  \edef\flashmovie@e@video{\flashmovieembedded}

  \immediate
  \pdfobj
    {<<
      /Instances
        [<<
          /Asset \flashmovie@e@video\space 0 R
          /Params << /Binding /Foreground >>
        >>]
      /Subtype /Flash
    >>}
  \configurationnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Assets << /Names [(#2) \flashmovie@e@video\space 0 R] >>
      /Configurations [\the\configurationnum\space 0 R]
    >>}
  \contentnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PO 
           /Configuration \the\configurationnum\space 0 R 
           /Animation 
             << /Subtype /Linear 
                /Speed 1 
                /Playcount 1 
             >> 
           /Presentation
             << /PassContextClick false
                /Style /Embedded 
                /Toolbar false
                /NavigationPane false
                /Transparent true
                /Window 
                  << /Type /RichMediaWindow 
                     /Width  << /Default 100 /Min 100 /Max 100 >> 
                     /Height << /Default 100 /Min 100 /Max 100 >> 
                     /Position 
                       << /Type /RichMediaPosition 
                          /HAlign /Near 
                          /VAlign /Near 
                          /HOffset 0 
                          /VOffset 0 
                       >> 
                  >> 
              >> 
        >> 
      /Deactivation 
        << /Type /RichMediaDeactivation 
           /Condition /XD 
        >> 
    >>}
  \settingsnum=\pdflastobj

  \sbox{\flashmovie@content} {{\hbox to \flashmoviewidth {\vbox to \flashmovieheight { }}}}

  \settowidth {\flashmovie@width} {\usebox{\flashmovie@content}}
  \settoheight{\flashmovie@height}{\usebox{\flashmovie@content}}
  \usebox{\flashmovie@content}

  \pdfannot width \flashmovie@width height \flashmovie@height depth 0pt {
       /Subtype /RichMedia
       /RichMediaContent  \the\contentnum\space 0 R 
       /RichMediaSettings \the\settingsnum\space 0 R 
}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% player from adobe acrobat pro

\def\flashmovie@acropro{\@ifnextchar[\@flashmovie@acropro{\@flashmovie@acropro[]}}

\def\@flashmovie@acropro[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \newcount\configurationnum
  \newcount\contentnum
  \newcount\settingsnum

  \flashmovieembedfile{#2}
  \edef\flashmovie@e@video{\flashmovieembedded}

  \flashmovieembedfile{SkinOverPlaySeekStop.swf}
  \edef\flashmovie@e@skin{\flashmovieembedded}

  \flashmovieembedfile{VideoPlayer.swf}
  \edef\flashmovie@e@player{\flashmovieembedded}
  
  \immediate
  \pdfobj
    {<<
      /Instances
        [<<
          /Asset \flashmovie@e@player\space 0 R
          /Params 
            << 
               /Binding /Foreground
               /FlashVars (source=#2&skin=SkinOverPlaySeekStop.swf&skinAutoHide=true&skinBackgroundColor=0x00FF00&skinBackgroundAlpha=0.33&volume=1.00)
            >>
        >>]
      /Subtype /Flash
    >>}
  \configurationnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Assets << /Names [(#2) \flashmovie@e@video\space 0 R (skinover.swf) \flashmovie@e@skin\space 0 R (VideoPlayer.swf) \flashmovie@e@player\space 0 R] >>
      /Configurations [\the\configurationnum\space 0 R]
    >>}
  \contentnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PO 
           /Configuration \the\configurationnum\space 0 R 
           /Animation 
             << /Subtype /Linear 
                /Speed 1 
                /Playcount 1 
             >> 
           /Presentation
             << /PassContextClick false
                /Style /Embedded 
                /Toolbar false
                /NavigationPane false
                /Transparent true
                /Window 
                  << /Type /RichMediaWindow 
                     /Width  << /Default 100 /Min 100 /Max 100 >> 
                     /Height << /Default 100 /Min 100 /Max 100 >> 
                     /Position 
                       << /Type /RichMediaPosition 
                          /HAlign /Near 
                          /VAlign /Near 
                          /HOffset 0 
                          /VOffset 0 
                       >> 
                  >> 
              >> 
        >> 
      /Deactivation 
        << /Type /RichMediaDeactivation 
           /Condition /XD 
        >> 
    >>}
  \settingsnum=\pdflastobj

  \sbox{\flashmovie@content} {{\hbox to \flashmoviewidth {\vbox to \flashmovieheight { }}}}

  \settowidth {\flashmovie@width} {\usebox{\flashmovie@content}}
  \settoheight{\flashmovie@height}{\usebox{\flashmovie@content}}
  \usebox{\flashmovie@content}

  \pdfannot width \flashmovie@width height \flashmovie@height depth 0pt {
       /Subtype /RichMedia
       /RichMediaContent  \the\contentnum\space 0 R 
       /RichMediaSettings \the\settingsnum\space 0 R 
}}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% flv-player from http://flv-player.net/players/maxi

\def\flashmovie@flvplayer{\@ifnextchar[\@flashmovie@flvplayer{\@flashmovie@flvplayer[]}}

\def\@flashmovie@flvplayer[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \newcount\configurationnum
  \newcount\contentnum
  \newcount\settingsnum

  \flashmovieembedfile{#2}
  \edef\flashmovie@e@video{\flashmovieembedded}

  \flashmovieembedfile{player_flv_maxi.swf}
  \edef\flashmovie@e@player{\flashmovieembedded}

  % startimage is initialized here
  \ifx\flashmovieimage\flashmovieempty
    \def\flashmovieimagevari{}
    \def\flashmovieimagevarii{}
  \else
    \flashmovieembedfile{\flashmovieimage}
    \edef\flashmovie@e@image{\flashmovieembedded}
    \def\flashmovieimagevari{&startimage=\flashmovieimage}
    \def\flashmovieimagevarii{(\flashmovieimage) \flashmovie@e@image\space 0 R}
  \fi

  % autoplay is initialized here
  \ifx\flashmovieauto\flashmoviezero
    \def\flashmovieautovari{}
  \else
    \def\flashmovieautovari{&autoplay=1}
  \fi

  \immediate
  \pdfobj
    {<<
      /Instances
        [<<
          /Asset \flashmovie@e@player\space 0 R
          /Params 
            << 
               /Binding /Foreground
               /FlashVars (flv=#2&margin=0&showvolume=1&showstop=1&showtime=1&videobgcolor=0xFFFFFF&\flashmovieautovari\flashmovieimagevari&loop=1)
            >>
        >>]
      /Subtype /Flash
    >>}
  \configurationnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Assets << /Names 
       [(#2) \flashmovie@e@video\space 0 R (player_flv_maxi.swf) \flashmovie@e@player\space 0 R \flashmovieimagevarii] >>
      /Configurations [\the\configurationnum\space 0 R]
    >>}
  \contentnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PO 
           /Configuration \the\configurationnum\space 0 R 
           /Animation 
             << /Subtype /Linear 
                /Speed 1 
                /Playcount 1 
             >> 
           /Presentation
             << /PassContextClick false
                /Style /Embedded 
                /Toolbar false
                /NavigationPane false
                /Transparent true
                /Window 
                  << /Type /RichMediaWindow 
                     /Width  << /Default 100 /Min 100 /Max 100 >> 
                     /Height << /Default 100 /Min 100 /Max 100 >> 
                     /Position 
                       << /Type /RichMediaPosition 
                          /HAlign /Near 
                          /VAlign /Near 
                          /HOffset 0 
                          /VOffset 0 
                       >> 
                  >> 
              >> 
        >> 
      /Deactivation 
        << /Type /RichMediaDeactivation 
           /Condition /XD 
        >> 
    >>}
  \settingsnum=\pdflastobj

  \sbox{\flashmovie@content} {{\hbox to \flashmoviewidth {\vbox to \flashmovieheight { }}}}

  \settowidth {\flashmovie@width} {\usebox{\flashmovie@content}}
  \settoheight{\flashmovie@height}{\usebox{\flashmovie@content}}
  \usebox{\flashmovie@content}

  \pdfannot width \flashmovie@width height \flashmovie@height depth 0pt {
       /Subtype /RichMedia
       /RichMediaContent  \the\contentnum\space 0 R 
       /RichMediaSettings \the\settingsnum\space 0 R }
}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% JW Player from http://www.longtailvideo.com/players/jw-flv-player/

\def\flashmovie@jwplayer{\@ifnextchar[\@flashmovie@jwplayer{\@flashmovie@jwplayer[]}}

\def\@flashmovie@jwplayer[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \newcount\configurationnum
  \newcount\contentnum
  \newcount\settingsnum

  \flashmovieembedfile{#2}
  \edef\flashmovie@e@video{\flashmovieembedded}

  \flashmovieembedfile{player.swf}
  \edef\flashmovie@e@player{\flashmovieembedded}

  \immediate
  \pdfobj
    {<<
      /Instances
        [<<
          /Asset \flashmovie@e@player\space 0 R
          /Params 
            << 
               /Binding /Foreground
               /FlashVars (file=#2)
            >>
        >>]
      /Subtype /Flash
    >>}
  \configurationnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Assets << /Names 
       [(#2) \flashmovie@e@video\space 0 R (player.swf) \flashmovie@e@player\space 0 R] >>
      /Configurations [\the\configurationnum\space 0 R]
    >>}
  \contentnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PO 
           /Configuration \the\configurationnum\space 0 R 
           /Animation 
             << /Subtype /Linear 
                /Speed 1 
                /Playcount 1 
             >> 
           /Presentation
             << /PassContextClick false
                /Style /Embedded 
                /Toolbar false
                /NavigationPane false
                /Transparent true
                /Window 
                  << /Type /RichMediaWindow 
                     /Width  << /Default 100 /Min 100 /Max 100 >> 
                     /Height << /Default 100 /Min 100 /Max 100 >> 
                     /Position 
                       << /Type /RichMediaPosition 
                          /HAlign /Near 
                          /VAlign /Near 
                          /HOffset 0 
                          /VOffset 0 
                       >> 
                  >> 
              >> 
        >> 
      /Deactivation 
        << /Type /RichMediaDeactivation 
           /Condition /XD 
        >> 
    >>}
  \settingsnum=\pdflastobj

  \sbox{\flashmovie@content} {{\hbox to \flashmoviewidth {\vbox to \flashmovieheight { }}}}

  \settowidth {\flashmovie@width} {\usebox{\flashmovie@content}}
  \settoheight{\flashmovie@height}{\usebox{\flashmovie@content}}
  \usebox{\flashmovie@content}

  \pdfannot width \flashmovie@width height \flashmovie@height depth 0pt {
       /Subtype /RichMedia
       /RichMediaContent  \the\contentnum\space 0 R 
       /RichMediaSettings \the\settingsnum\space 0 R }
}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OSFlvPlayer from http://www.osflv.com

\def\flashmovie@osplayer{\@ifnextchar[\@flashmovie@osplayer{\@flashmovie@osplayer[]}}

\def\@flashmovie@osplayer[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \newcount\configurationnum
  \newcount\contentnum
  \newcount\settingsnum

  \flashmovieembedfile{#2}
  \edef\flashmovie@e@video{\flashmovieembedded}

  \flashmovieembedfile{OSplayer.swf}
  \edef\flashmovie@e@player{\flashmovieembedded}

  \immediate
  \pdfobj
    {<<
      /Instances
        [<<
          /Asset \flashmovie@e@player\space 0 R
          /Params 
            << 
               /Binding /Foreground
               /FlashVars (movie=#2)
            >>
        >>]
      /Subtype /Flash
    >>}
  \configurationnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Assets << /Names 
       [(#2) \flashmovie@e@video\space 0 R (OSplayer.swf) \flashmovie@e@player\space 0 R] >>
      /Configurations [\the\configurationnum\space 0 R]
    >>}
  \contentnum=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PO 
           /Configuration \the\configurationnum\space 0 R 
           /Animation 
             << /Subtype /Linear 
                /Speed 1 
                /Playcount 1 
             >> 
           /Presentation
             << /PassContextClick false
                /Style /Embedded 
                /Toolbar false
                /NavigationPane false
                /Transparent true
                /Window 
                  << /Type /RichMediaWindow 
                     /Width  << /Default 100 /Min 100 /Max 100 >> 
                     /Height << /Default 100 /Min 100 /Max 100 >> 
                     /Position 
                       << /Type /RichMediaPosition 
                          /HAlign /Near 
                          /VAlign /Near 
                          /HOffset 0 
                          /VOffset 0 
                       >> 
                  >> 
              >> 
        >> 
      /Deactivation 
        << /Type /RichMediaDeactivation 
           /Condition /XD 
        >> 
    >>}
  \settingsnum=\pdflastobj

  \sbox{\flashmovie@content} {{\hbox to \flashmoviewidth {\vbox to \flashmovieheight { }}}}

  \settowidth {\flashmovie@width} {\usebox{\flashmovie@content}}
  \settoheight{\flashmovie@height}{\usebox{\flashmovie@content}}
  \usebox{\flashmovie@content}

  \pdfannot width \flashmovie@width height \flashmovie@height depth 0pt {
       /Subtype /RichMedia
       /RichMediaContent  \the\contentnum\space 0 R 
       /RichMediaSettings \the\settingsnum\space 0 R }
}}