summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/flashmovie/flashmovie.sty
blob: 865fa0a25058bfdbffdbc6ac096a11013e29ccd4 (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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
%%%%%%%%%%%%% flashmovie.sty
%%%%%%%%%%%%% Copyright 2010 Timo Hartmann (thartmann15 at googlemail.com)
%
% Version 0.4
%
% changelog:
%   0.4 : 2010-09-13 : better support for jw-player, minor bug fixes
%   0.3 : 2010-09-09 : better examples,minor bug fixes, issues with beamer explained
%   0.2 : 2010-04-21 : major overhaul: keyval 'engine', flv-player-engine,
%                                      efficient multiple embedding of files,...
%   0.1 : 2010-04-13 : a bunch of bugfixes
%   0.0 : 2009-12-06 : initial release
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% 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 (depending on the player).
%       See example (2) below.
%   Using the keyword "engine" one can select the method of embedding.
%   If you omit it or if you specify "engine=pure-swf" then the file will be
%   directly embedded. This works only for swf-files.
%   For other possible values of "engine" see the chapter "flash-video-players".
%
% supported file formats:
%   - flash animations ( ".swf" files) via direct embedding
%   - mp4 movies (".mp4" files) via an embedded flash-video-player
%   - flv movies (".flv" files) via an embedded flash-video-player
%
%   attention:
%     - avi videos (".avi" files) don't work !
%
% 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. But there seems to be some
%   incompatibilities of flv-player and beamer. See troubleshooting below.
%
%   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=someimage.jpeg     --> start-image (not necessary)
%
%    - "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. Its released under a creative common license which means its free
%      for non-commercial use.
%      It is NOT included in this distribution.
%
%      supported parameters:
%        auto=0                   --> auto-play off (default)
%        auto=1                   --> auto-play on
%        image=someimage.jpeg     --> start-image (not necessary)
%        controlbar=0             --> no control bar shown
%        controlbar=1             --> control bar shown (default)
%        loop=0                   --> do not loop the video (default)
%        loop=1                   --> loop the video
%
%    - "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=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 in this distribution.
%      For this player flashmovie.sty only provides rudimentary support.
%
%   other options for the "engine"-keyword:
%    - "engine=pure-swf" : This directly embedds the file into the PDF without 
%      any flash-video-player. This is the default option when you omit the 
%      "engine"-keyword. This works only for swf-files.
%    - "engine=blank" : This simply produces an empty rectangle instead of an
%      flash animation. This is useful during the creation process of the 
%      PDF because flash animations inside a PDF can easily crash 
%      the Adobe reader with the reload (CTRL-R) feature after recompiling
%      the tex-file. 
%      The same effect can be produced if uses "blank=1" as an option 
%      regardless what the value of "engine" is.
%      example: \flashmovie[...,engine=flv-player,blank=1,...]{...}
%
%
% 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
%
% how to produce swf-files:
%   - ffmpeg or mencoder : transform a video file into a flash animation (example: .mp4 --> .swf)
%   - png2swf : transform a sequence of png files into a flash animation (example: .png --> .swf)
%   - flex sdk : use action script to program your own flash applet
%   - mtasc and swfmill : use action script to program your own flash applet (outdated, should not be used)
%
% todo:
%   - make more options of rich-media annotations usable, for example activation by clicking, play-count,...
%
% tips:
%   - It is in principle possible to insert any flash animation into a PDF.
%     One is not restricted to videos.
%   - During development of the PDF one can switch of the flash animations which
%     is sometimes useful. See "engine=blank" or "blank=1" for more information.
%
% troubleshooting:
%   - If you encounter the error message "\pdfminorversion cannot be changed after data is written to the PDF file.",
%     then another package is also setting the variable "\pdfminorversion".
%     For example the package "beamer" does so.
%     There are two solutions: 
%      - Include the package with the highest "\pdfminorversion" first.
%        For example put "\RequirePackage{flashmovie}" on the very first line 
%        of your file instead of using "\usepackage{flashmovie}" later on.
%        Or rearrange the usepackage-commands in the right order.
%      - Comment the line "\ifnum\pdfminorversion<7 \pdfminorversion=7\fi" in
%        "flashmovie.sty". This will probably leave your PDF with the wrong 
%        version information, but the Adobe Reader will take it anyway.
%   - There seems to be some trouble with the latex package beamer. You can't use
%     the flv-player reliably with it. It is prone to crash the acrobat reader while
%     changing pages.
%     The only reliable way to use beamer seems to be directly embedding the videos as
%     flash animations or to use the JW player.
%
% warning:
%   - It is recommended to use always the latest available version of the Adobe Reader. 
%     This should be mandatory because in the past many attacks on computers were based
%     on 'evil' PDFs which exploited security holes in this software.
%   - 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{}
  \def\flashmoviekblank{0}
  \def\flashmoviecontrolbar{1}
  \def\flashmovieloop{0}
}

\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}}
\define@key{flashmovieparams}{blank}      {\def\flashmoviekblank {#1}}
\define@key{flashmovieparams}{controlbar} {\def\flashmoviecontrolbar{#1}}
\define@key{flashmovieparams}{loop}       {\def\flashmovieloop{#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}{

  \ifthenelse{\equal{\flashmoviekblank}{\flashmoviezero}}
   {}{\def\flashmovieengine{blank}}

  \ifx\flashmovieengine\flashmovieempty
    \flashmovie@pureswf[#1]{#2}
  \else

    \ifthenelse{\equal{\flashmovieengine}{pure-swf}}
    {\flashmovie@pureswf[#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}}{}

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

  \fi
}}

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

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

\def\@flashmovie@pureswf[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \newcount\flashmovie@n@config
  \newcount\flashmovie@n@content
  \newcount\flashmovie@n@settings

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

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

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

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PV
           /Configuration \the\flashmovie@n@config\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 /PI
        >> 
    >>}
  \flashmovie@n@settings=\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\flashmovie@n@content\space 0 R 
       /RichMediaSettings \the\flashmovie@n@settings\space 0 R 
}}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% blank

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

\def\@flashmovie@blank[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \sbox{\flashmovie@content} {{\hbox to \flashmoviewidth {\vbox to \flashmovieheight { }}}}
  \settowidth {\flashmovie@width} {\usebox{\flashmovie@content}}
  \settoheight{\flashmovie@height}{\usebox{\flashmovie@content}}
  \usebox{\flashmovie@content}
}}

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

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

\def\@flashmovie@acropro[#1]#2{\flashmovieparamsclear \setkeys{flashmovieparams}{#1}{
  \newcount\flashmovie@n@config
  \newcount\flashmovie@n@content
  \newcount\flashmovie@n@settings

  \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
    >>}
  \flashmovie@n@config=\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\flashmovie@n@config\space 0 R]
    >>}
  \flashmovie@n@content=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PV
           /Configuration \the\flashmovie@n@config\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 /PI
        >> 
    >>}
  \flashmovie@n@settings=\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\flashmovie@n@content\space 0 R 
       /RichMediaSettings \the\flashmovie@n@settings\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\flashmovie@n@config
  \newcount\flashmovie@n@content
  \newcount\flashmovie@n@settings

  \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

  % looping is initialized here
  \ifx\flashmovieloop\flashmoviezero
    \def\flashmovieloopvari{&loop=0}
  \else
    \def\flashmovieloopvari{&loop=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\flashmovieloopvari)
            >>
        >>]
      /Subtype /Flash
    >>}
  \flashmovie@n@config=\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\flashmovie@n@config\space 0 R]
    >>}
  \flashmovie@n@content=\pdflastobj

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PV
           /Configuration \the\flashmovie@n@config\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 /PI
        >> 
    >>}
  \flashmovie@n@settings=\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\flashmovie@n@content\space 0 R 
       /RichMediaSettings \the\flashmovie@n@settings\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\flashmovie@n@config
  \newcount\flashmovie@n@content
  \newcount\flashmovie@n@settings

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

  \flashmovieembedfile{player.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{&image=\flashmovieimage}
    \def\flashmovieimagevarii{(\flashmovieimage) \flashmovie@e@image\space 0 R}
  \fi

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

  % controlbar is initialized here
  \ifx\flashmoviecontrolbar\flashmoviezero
    \def\flashmoviecontrolbarvari{&controlbar=none}
  \else
    \def\flashmoviecontrolbarvari{}
  \fi

  % looping is initialized here
  \ifx\flashmovieloop\flashmoviezero
    \def\flashmovieloopvari{}
  \else
    \def\flashmovieloopvari{&repeat=always}
  \fi

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

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

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PV
           /Configuration \the\flashmovie@n@config\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 /PI
        >> 
    >>}
  \flashmovie@n@settings=\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\flashmovie@n@content\space 0 R 
       /RichMediaSettings \the\flashmovie@n@settings\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\flashmovie@n@config
  \newcount\flashmovie@n@content
  \newcount\flashmovie@n@settings

  \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
    >>}
  \flashmovie@n@config=\pdflastobj

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

  \immediate
  \pdfobj
    {<<
      /Activation 
        << /Type /RichMediaActivation 
           /Condition /PV
           /Configuration \the\flashmovie@n@config\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 /PI
        >> 
    >>}
  \flashmovie@n@settings=\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\flashmovie@n@content\space 0 R 
       /RichMediaSettings \the\flashmovie@n@settings\space 0 R }
}}