summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/media9
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-05-05 00:42:08 +0000
committerKarl Berry <karl@freefriends.org>2012-05-05 00:42:08 +0000
commit440129bde78c9900f848a8225a5577223a4837b6 (patch)
tree35092add7c86eb44925011de49efaf1f17dd43d2 /Master/texmf-dist/doc/latex/media9
parentfedd1465e14e7640fb141f97161d85acbfc6c111 (diff)
media9 (2may12)
git-svn-id: svn://tug.org/texlive/trunk@26204 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/latex/media9')
-rw-r--r--Master/texmf-dist/doc/latex/media9/ChangeLog10
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/cube.asy46
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/cube.mp4bin0 -> 295207 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml130
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml85
-rw-r--r--Master/texmf-dist/doc/latex/media9/media9.pdfbin1261350 -> 1560925 bytes
-rw-r--r--Master/texmf-dist/doc/latex/media9/media9.tex139
7 files changed, 317 insertions, 93 deletions
diff --git a/Master/texmf-dist/doc/latex/media9/ChangeLog b/Master/texmf-dist/doc/latex/media9/ChangeLog
index 4bd86f71d3e..381076589f7 100644
--- a/Master/texmf-dist/doc/latex/media9/ChangeLog
+++ b/Master/texmf-dist/doc/latex/media9/ChangeLog
@@ -1,3 +1,13 @@
+2012-05-02
+ * v0.7
+ * new: 3Dpartsattrs added as package option
+
+2012-04-25
+ * v0.6
+ * new: command options added: 3Dpartsattrs, label;
+ updated APlayer and VPlayer versions with exposed ActionScript functions
+ for player control from JavaScript
+
2012-04-16
* v0.5
* fix: option 3Dortho did not work, documentation update
diff --git a/Master/texmf-dist/doc/latex/media9/files/cube.asy b/Master/texmf-dist/doc/latex/media9/files/cube.asy
new file mode 100644
index 00000000000..606375763d5
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/cube.asy
@@ -0,0 +1,46 @@
+import math;
+import bsp;
+import animation;
+
+size(100,100);
+
+animation a;
+
+void face(face[] faces, path3 p, int j, int k) {
+ picture pic=faces.push(p);
+ filldraw(pic,project(p),Pen(j));
+ int sign=(k % 2 == 0) ? 1 : -1;
+ transform t=scale(4)*transform(dir(p,0,sign),dir(p,0,-sign));
+ label(pic,t*(string) j,project(0.5*(min(p)+max(p))));
+}
+
+void snapshot(transform3 t)
+{
+ static transform3 s=shift(-0.5*(X+Y+Z));
+ save();
+
+ face[] faces;
+ int j=-1;
+ transform3 T=t*s;
+ for(int k=0; k < 2; ++k) {
+ face(faces,T*plane((1,0,0),(0,1,0),(0,0,k)),++j,k);
+ face(faces,T*plane((0,1,0),(0,0,1),(k,0,0)),++j,k);
+ face(faces,T*plane((0,0,1),(1,0,0),(0,k,0)),++j,k);
+ }
+ add(faces);
+
+ a.add();
+ restore();
+}
+
+int n=50;
+
+real step=360/n;
+for(int i=0; i < n; ++i)
+ snapshot(rotate(i*step,X));
+for(int i=0; i < n; ++i)
+ snapshot(rotate(i*step,Y));
+for(int i=0; i < n; ++i)
+ snapshot(rotate(i*step,Z));
+
+a.movie(loops=1,delay=50);
diff --git a/Master/texmf-dist/doc/latex/media9/files/cube.mp4 b/Master/texmf-dist/doc/latex/media9/files/cube.mp4
new file mode 100644
index 00000000000..af2cb8c0331
--- /dev/null
+++ b/Master/texmf-dist/doc/latex/media9/files/cube.mp4
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml b/Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml
index 67375fb6a06..cffab803f7e 100644
--- a/Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml
+++ b/Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml
@@ -4,7 +4,7 @@
<!-- a FlashPlayer-10 compatible component for playing -->
<!-- MP3 audio files and streams. -->
<!-- -->
-<!-- version 20120301 -->
+<!-- version 20120425 -->
<!-- -->
<!-- -->
<!-- The free Adobe Flex 4 SDK is required to compile -->
@@ -41,16 +41,17 @@
xmlns:mx="library://ns.adobe.com/flex/mx"
preinitialize="initialise(FlexGlobals.topLevelApplication.parameters);"
applicationComplete="initSound();addEventListener(Event.ENTER_FRAME, onEnterFrame);"
+ creationComplete="initCallBacks();"
mouseDown="pause();"
mouseUp="play();"
>
-
+
<fx:Script>
<![CDATA[
[Bindable] private var source:String;
[Bindable] private var autoPlay:Boolean=false;
[Bindable] private var loop:Boolean=false;
- [Bindable] private var volume:Number=0.75;
+ [Bindable] private var vol:Number=0.75;
[Bindable] private var balance:Number=0;
private var snd:Sound;
@@ -58,81 +59,130 @@
private var sndTr:SoundTransform;
private var playResumePosition:Number = 0;
private var playing:Boolean = false;
+ private var muted:Boolean = false;
+ private var lastVol:Number;
import mx.core.FlexGlobals;
- private function initialise(flashVars:Object):void{
+ private function initialise(flashVars:Object):void {
source=flashVars.source;
if(flashVars.autoPlay){autoPlay=(flashVars.autoPlay=='true')}
if(flashVars.loop){loop=(flashVars.loop=='true')}
- if(flashVars.volume){volume=Number(flashVars.volume)}
+ if(flashVars.volume){vol=Number(flashVars.volume)}
if(flashVars.balance){balance=Number(flashVars.balance)}
}
-
+
import mx.controls.Alert;
- private function initSound():void
- {
- snd = new Sound(new URLRequest(source));
- sndTr = new SoundTransform(volume, balance);
-
- snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
- snd.addEventListener(ProgressEvent.PROGRESS, progressHandler);
- snd.addEventListener(Event.COMPLETE, completeHandler);
-
- if(autoPlay) play();
- }
-
- private function play():void
- {
- if (!playing)
- {
+ private function initSound():void {
+ snd = new Sound(new URLRequest(source));
+ sndTr = new SoundTransform(vol, balance);
+
+ snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
+ snd.addEventListener(ProgressEvent.PROGRESS, progressHandler);
+ snd.addEventListener(Event.COMPLETE, completeHandler);
+
+ if(autoPlay) play();
+ }
+
+ private function setSource(src:String):void {
+ pause();
+ snd = new Sound(new URLRequest(src));
+ if(autoPlay) play();
+ }
+
+ private function play():void {
+ if (!playing) {
try{sndCh = snd.play(playResumePosition, 0, sndTr);}
catch(err:Error){Alert.show(err.message,'Error');}
sndCh.addEventListener(Event.SOUND_COMPLETE, sndCompleteHandler);
playing = true;
}
}
-
- private function pause():void
- {
- if (playing)
- {
+
+ private function pause():void {
+ if (playing) {
playResumePosition = sndCh.position;
sndCh.stop();
playing = false;
}
}
- private function sndCompleteHandler(event:Event):void
- {
+ private function playPause():void {
+ if (playing) pause(); else play();
+ }
+
+ private function seek(p:Number):void {
+ playResumePosition = p*1000;
+ if (playing) {
+ sndCh.stop();
+ playing = false;
+ play();
+ }
+ }
+
+ private function rewind():void {
+ seek(0);
+ }
+
+ private function volume(v:Number):void {
+ sndTr.volume = v;
+ if (playing) {
+ pause();
+ play();
+ }
+ }
+
+ private function mute():void {
+ if(muted) {
+ if (lastVol==0) lastVol=0.75;
+ volume(lastVol);
+ muted=false;
+ }
+ else {
+ lastVol = sndTr.volume
+ volume(0);
+ muted=true;
+ }
+ }
+
+ private function initCallBacks():void {
+ ExternalInterface.addCallback("play", play);
+ ExternalInterface.addCallback("pause", pause);
+ ExternalInterface.addCallback("playPause", playPause);
+ ExternalInterface.addCallback("seek", seek);
+ ExternalInterface.addCallback("rewind", rewind);
+ ExternalInterface.addCallback("volume", volume);
+ ExternalInterface.addCallback("mute", mute);
+ ExternalInterface.addCallback("setSource", setSource);
+ }
+
+ private function sndCompleteHandler(event:Event):void {
playing = false;
playResumePosition = 0;
if(loop) play();
}
-
- private function completeHandler(event:Event):void
- {
+
+ private function completeHandler(event:Event):void {
playProgress.indeterminate=false;
}
-
+
import flash.events.ProgressEvent;
- private function progressHandler(event:ProgressEvent):void{
+ private function progressHandler(event:ProgressEvent):void {
playProgress.indeterminate=true;
- if(playing){
+ if(playing) {
playProgress.setProgress(0.5,1);
}
}
-
- private function onEnterFrame(event:Event):void{
- if(playProgress.indeterminate==false && playing){
+
+ private function onEnterFrame(event:Event):void {
+ if(playProgress.indeterminate==false && playing) {
playProgress.setProgress(sndCh.position,snd.length);
}
}
import flash.events.IOErrorEvent;
- private function errorHandler(errorEvent:IOErrorEvent):void{
+ private function errorHandler(errorEvent:IOErrorEvent):void {
Alert.show(errorEvent.text + '\ncould not be loaded','Error');
}
-
]]>
</fx:Script>
diff --git a/Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml b/Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml
index 9d070ed2d40..1c71c751c08 100644
--- a/Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml
+++ b/Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml
@@ -4,7 +4,7 @@
<!-- a FlashPlayer-10 compatible component for playing -->
<!-- FLV and MP4/H.264 video files and streams. -->
<!-- -->
-<!-- version 20120301 -->
+<!-- version 20120425 -->
<!-- -->
<!-- -->
<!-- The free Adobe Flex 4 SDK is required to compile -->
@@ -19,7 +19,7 @@
<!-- on the command line. -->
<!-- -->
<!-- -->
-<!-- Copyright (C) 2011 Alexander Grahn -->
+<!-- Copyright (C) 2012 Alexander Grahn -->
<!-- -->
<!-- This work may be distributed and/or modified under the -->
<!-- conditions of the LaTeX Project Public License, either -->
@@ -40,54 +40,107 @@
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
preinitialize="initialise(FlexGlobals.topLevelApplication.parameters);"
+ creationComplete="initCallBacks();"
>
<fx:Script>
<![CDATA[
+ [Bindable] private var scaleMode:String='stretch';
[Bindable] private var source:String;
[Bindable] private var autoPlay:Boolean=false;
[Bindable] private var loop:Boolean=false;
- [Bindable] private var volume:Number=0.75;
+ [Bindable] private var vol:Number=0.75;
private var vidComplete:Boolean=false;
import mx.core.FlexGlobals;
- private function initialise(flashVars:Object):void{
+ private function initialise(flashVars:Object):void {
source=flashVars.source;
if(flashVars.autoPlay){autoPlay=(flashVars.autoPlay=='true')}
if(flashVars.loop){loop=(flashVars.loop=='true')}
- if(flashVars.volume){volume=Number(flashVars.volume)}
+ if(flashVars.volume){vol=Number(flashVars.volume)}
+ if(flashVars.scaleMode){scaleMode=flashVars.scaleMode}
}
import flash.events.ProgressEvent;
- private function progressHandler(event:ProgressEvent):void{
+ private function progressHandler(event:ProgressEvent):void {
if (event.bytesTotal) event.target.visible=true;
- else event.target.visible=false;
- }
+ else event.target.visible=false;
+ }
import org.osmf.events.MediaPlayerStateChangeEvent;
import mx.controls.Alert;
- private function stateChangeHandler(event:MediaPlayerStateChangeEvent):void{
- vidComplete=false;
- if(event.state=='playbackError')
- Alert.show('Unable to play \''+event.target.source+'\'','Error');
- }
+ private function stateChangeHandler(event:MediaPlayerStateChangeEvent):void {
+ vidComplete=false;
+ if(event.state=='playbackError')
+ Alert.show('Unable to play \''+event.target.source+'\'','Error');
+ }
+
+ private function play():void {
+ if(vidComplete){vidDisp.seek(0);}vidDisp.play();
+ }
+
+ private function pause():void {
+ vidDisp.pause();
+ }
+
+ private function playPause():void {
+ if(vidDisp.playing) vidDisp.pause(); else vidDisp.play();
+ }
+
+ private function seek(p:Number):void {
+ vidDisp.seek(p);
+ }
+
+ private function rewind():void {
+ vidDisp.seek(0);
+ }
+
+ private function volume(v:Number):void {
+ vidDisp.volume = v;
+ }
+
+ private function mute():void {
+ if(vidDisp.muted) {
+ vidDisp.muted=false;
+ if (vidDisp.volume==0) volume(0.75);
+ }
+ else {
+ vidDisp.muted=true;
+ }
+ }
+
+ private function setSource(s:Object):void {
+ vidDisp.source = s;
+ }
+
+ private function initCallBacks():void {
+ ExternalInterface.addCallback("play", play);
+ ExternalInterface.addCallback("pause", pause);
+ ExternalInterface.addCallback("playPause", playPause);
+ ExternalInterface.addCallback("seek", seek);
+ ExternalInterface.addCallback("rewind", rewind);
+ ExternalInterface.addCallback("volume", volume);
+ ExternalInterface.addCallback("mute", mute);
+ ExternalInterface.addCallback("setSource", setSource);
+ }
]]>
</fx:Script>
<s:VideoDisplay
id="vidDisp"
- width="100%" height="100%" scaleMode="stretch"
- source="{source}" volume="{volume}"
+ width="100%" height="100%" scaleMode="{scaleMode}"
+ source="{source}" volume="{vol}"
autoPlay="{autoPlay}" autoRewind="false" loop="{loop}"
mouseDown="vidDisp.pause();"
mouseUp="if(vidComplete){vidDisp.seek(0);}vidDisp.play();"
mediaPlayerStateChange="stateChangeHandler(event);"
complete="vidComplete=true;"
+ durationChange="if(vidDisp.autoPlay) vidDisp.play(); else vidDisp.seek(0);"
/>
<mx:ProgressBar width="80%" mode="polled" source="vidDisp"
horizontalCenter="0" verticalCenter="0" labelPlacement="center"
id="loadingProgress" alpha="0.5"
complete="loadingProgress.visible=false;"
- progress="progressHandler(event)"
+ progress="progressHandler(event)"
/>
</s:Application>
diff --git a/Master/texmf-dist/doc/latex/media9/media9.pdf b/Master/texmf-dist/doc/latex/media9/media9.pdf
index 6e7f4e2475c..b6b3a308c46 100644
--- a/Master/texmf-dist/doc/latex/media9/media9.pdf
+++ b/Master/texmf-dist/doc/latex/media9/media9.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/media9/media9.tex b/Master/texmf-dist/doc/latex/media9/media9.tex
index 704709e3940..3dd9a124a5b 100644
--- a/Master/texmf-dist/doc/latex/media9/media9.tex
+++ b/Master/texmf-dist/doc/latex/media9/media9.tex
@@ -81,7 +81,7 @@ This package provides an interface to embed interactive Flash (SWF) and 3D objec
Among the supported media types, video and sound files require an additional Flash (SWF) application for playback, which must be either embedded into the PDF or loaded at runtime from the internet. There are numerous such players, both open-source and commercial, available on the internet. One of them is the highly configurable open-source `StrobeMediaPlayback.swf'~\cite{strobe}, maintained by Adobe and hosted on \href{http://sourceforge.net/projects/smp.adobe/files/}{SourceForge.net}. Package `media9' comes with an enhanced version of `StrobeMediaPlayback.swf'. In addition, two simple players for video and audio, `VPlayer.swf' and `APlayer.swf' are included, which can be used instead. They provide sufficient functionality for playing embedded files and streamed media.
-\emph{Note:} `media9' package replaces the now obsolete `movie15' package. `media9' is based on the RichMedia Annotation (Annotations are the interactive parts in a document, in PDF specification parlance.), an Adobe addition to the PDF specification~\cite{supplement}, while `movie15' uses the old multimedia framework (`Screen Annotation') of pre-9 Readers which depends on external plug-ins and which does not support recent media file formats.
+\emph{Note:} `media9' package replaces the now obsolete `movie15' package. `media9' is based on the RichMedia Annotation (Annotations are the interactive parts in a document, in PDF specification parlance.), an Adobe addition to the PDF specification~\cite{supplement}, while `movie15' uses the old multimedia framework (`Screen Annotation') of pre-9 Readers which depends on external plug-ins and which does not support recent media file formats.
Package `media9' supports the usual PDF making workflows, i.\,e. pdf\LaTeX{}, Lua\LaTeX, \LaTeX{} $\rightarrow$ \verb+dvips+ $\rightarrow$ \verb+ps2pdf+/Distiller and \pXepLaTeX{} $\rightarrow$ \verb+(x)dvipdfmx+.
@@ -133,6 +133,7 @@ passcontext
3Dplayspeed=...
3Dtoolbar
3Dnavpane
+3Dpartsattrs=...
3Dmenu
3Dbg=...
3Dlights=...
@@ -172,7 +173,12 @@ width=<width>,
height=<height>,
depth=<depth>
\end{verbatim}
-Resize the media playback area, overriding the original dimensions of the {\tt<poster text>} argument. Option `\verb+depth+' specifies how far the playback area should extend below the base line of the running text. If only one or two of these options are given, the remaining, unspecified dimensions are scaled to maintain the aspect ratio of \verb+<poster text>+. Any valid \TeX{} dimension is accepted as a parameter. In addition, the length commands \verb+\width+, \verb+\height+, \verb+\depth+ and \verb+\totalheight+ can be used to refer to the original dimensions of \verb+<poster text>+.
+Resize the media playback area, overriding the original dimensions of the {\tt<poster text>} argument. Option `\verb+depth+' specifies how far the playback area should extend below the base line of the running text. If only one of `\verb+width+' or `\verb+height+' is given, the other dimension is scaled to maintain the aspect ratio of \verb+<poster text>+. Any valid \TeX{} dimension is accepted as a parameter. In addition, the length commands \verb+\width+, \verb+\height+, \verb+\depth+ and \verb+\totalheight+ can be used to refer to the original dimensions of \verb+<poster text>+.
+
+\begin{verbatim}
+label=<label string>
+\end{verbatim}
+The media annotation is given a label, \verb+<label string>+, which should be unique. This option defines JavaScript reference \verb+annotRM['<label string>']+ for easy accessing the media annotation object from within JavaScript. Note that the reference is known only after the first opening of the page containing the media. For an example, see Fig.~\ref{videoa}.
\begin{verbatim}
scale=<factor>
@@ -206,11 +212,11 @@ if, for a particular media player, the video source is set through ActionScript
(Note for 3D) Resource files used in 3D scenes cannot be loaded by means of ActionScript variables. This must be done by 3D JavaScript during activation of the 3D scene in the Reader. 3D JavaScript can be attached using option `\verb+add3Djscript+', see below.
\begin{verbatim}
-activate=onclick | pageopen | pagevisible
+activate=onclick | pageopen | pagevisible
\end{verbatim}
Decides on how to activate the media annotation. `\verb+activate=onclick+' is default behaviour and does not need be given explicitly; embedded media is activated when the user clicks on it or by a JavaScript. It is recommended to provide a poster image with the \verb+<poster text>+ argument in that case. `\verb+pageopen+' and `\verb+pagevisible+' automatically activate the media when the page becomes visible; `{\tt pagevisible}' is better for two-up and continuous page display.
\begin{verbatim}
-deactivate=onclick | pageclose | pageinvisible
+deactivate=onclick | pageclose | pageinvisible
\end{verbatim}
Decides on how to de-activate the media annotation. `\verb+deactivate=pageclose+' is default behaviour and does not need be given explicitly; media is automatically de-activated when the user leaves the page containing the media. `\verb+pageinvisible+' is similar, but may be better for two-up and continuous page display. Setting `\verb+deactivate=onclick+' requires user interaction for de-activating the media, either by right-click and chosing `\emph{\sffamily Disable Content}' or by a JavaScript.
\begin{verbatim}
@@ -268,7 +274,7 @@ Switches from the default perspective to orthographic view mode. In orthographic
\end{verbatim}
Mainly used during document authoring. Adds three entries, `\emph{\sffamily Generate Default View}', `\emph{\sffamily Get Current View}' and `\emph{\sffamily Cross Section}' to the context (right-click) menu of an activated 3D annotation. Moreover, it allows individual parts of the scene to be scaled, translated and rotated against the remaining scene objects using the keyboard. Their new position can be saved in the current view. Parts to be modified should be highlighted with the mouse first (the part's bounding box becomes visible). Then, arrow keys \keys{\arrowkeyleft}, \keys{\arrowkeyright} let the part spin around its vertical axis, and \keys{\arrowkeyup}, \keys{\arrowkeydown} tilt against the vertical position. \keys{X}, \keys{\shift+X}, \keys{Y}, \keys{\shift+Y}, \keys{Z}, \keys{\shift+Z} translate the selected part along the World axes and \keys{S}, \keys{\shift+S} scale the part.
-`\emph{\sffamily Generate Default View}' computes optimal camera settings such that the visual parts of the object fit tightly into the viewing area. The result is printed, formatted as a list of \verb+\includemedia+ options, into the JavaScript console. The calculation is based on the 3D object size and its position in the World coordinate system as well as the current viewing mode (perspective or orthographic).
+`\emph{\sffamily Generate Default View}' computes optimal camera settings such that the visual parts of the object fit tightly into the viewing area. The result is printed, formatted as a list of \verb+\includemedia+ options, into the JavaScript console. The calculation is based on the 3D object size and its position in the World coordinate system as well as the current viewing mode (perspective or orthographic).
`\emph{\sffamily Cross Section}' is a toggle switch to add or remove a cross section to or from the current view. If a part of the 3D scene was previously selected, the central rotating point of the section plane is put into the part's centre, otherwise into the target point of the camera. The section plane can be rotated around the vertical axis and tilted against its upright position using the arrow keys \keys{\arrowkeyleft}, \keys{\arrowkeyright}, \keys{\arrowkeyup} and \keys{\arrowkeydown}. Keys \keys{X}, \keys{\shift+X}, \keys{Y}, \keys{\shift+Y}, \keys{Z}, \keys{\shift+Z} move the section plane along the World axes.
@@ -289,9 +295,13 @@ Sets the default lighting scheme. The following values are honoured: `\verb+None
Sets the default render mode. The following values are honoured: `\verb+Solid+', `\verb+SolidWireframe+', `\verb+Transparent+', `\verb+TransparentWireframe+', `\verb+BoundingBox+', `\verb+TransparentBoundingBox+', `\verb+TransparentBoundingBoxOutline+', `\verb+Wireframe+', `\verb+ShadedWireframe+', `\verb+HiddenWireframe+', `\verb+Vertices+', `\verb+ShadedVertices+', `\verb+SolidOutline+', `\verb+Illustration+', `\verb+ShadedIllustration+'.
\end{flushleft}
\begin{verbatim}
+3Dpartsattrs=restore | keep
+\end{verbatim}
+When the user selects another view from the list of predefined views (see option `\verb+3Dviews+'), attributes of individual parts, such as opacity, visibility, render mode, translation in space, which all can be set from within the Reader or by means of a file of predefined views, are reset to their original states as defined in the embedded 3D file, before any new part settings are applied. This default behaviour can be overridden by `\verb+3Dpartsattrs=keep+'. This will preserve current part attributes when the user selects another predefined 3D view in the Reader.
+\begin{verbatim}
3Dviews=<views file>
\end{verbatim}
-Instead of or in addition to the default view (options `\verb+3Dcoo+', `\verb+3Dc2c+', `\verb+3Droll+', `\verb+3Droo+', `\verb+3Daac+', `\verb+3Dortho+'), further \emph{named views} can be set in an auxiliary file \verb+<views file>+. Besides the virtual camera position, it is possible to adjust the rendering attributes, such as visibility and transparency, as well as position and scaling of every single part in the 3D scene. Moreover, background colour and scene lighting can be set individually for every view. The additional views can later be selected either from a drop down list in the tool bar that is associated with the activated 3D object in the Reader or from the context menu of the 3D object.
+Instead of or in addition to the default view (options `\verb+3Dcoo+', `\verb+3Dc2c+', `\verb+3Droll+', `\verb+3Droo+', `\verb+3Daac+', `\verb+3Dortho+'), further \emph{named views} can be predefined in an auxiliary file \verb+<views file>+. Besides the virtual camera position, it is possible to adjust the rendering attributes, such as visibility and transparency, as well as position and scaling of every single part in the 3D scene. Moreover, background colour and scene lighting can be set individually for every view. The additional views can later be selected either from a drop down list in the tool bar that is associated with the activated 3D object in the Reader or from the context menu of the 3D object.
The file \verb+<views file>+ is structured into view sections, one for every view:
\begin{verbatim}
@@ -309,7 +319,8 @@ The file \verb+<views file>+ is structured into view sections, one for every vie
CROSSSECT
CENTER=<x> <y> <z>
NORMAL=<x> <y> <z>
- END
+ END
+ PARTSATTRS=keep
PART=<part name as in the Model Tree (required, optional if UTF16NAME present)>
UTF16NAME=<part name as hex encoded Unicode string>
VISIBLE=true | false
@@ -337,7 +348,7 @@ A view section may contain at most one \verb+CROSSSECT+ sub-section. It inserts
The views file can be commented. As usual, comments start with the percent sign.
-To facilitate the creation of a views file, option `\verb+3Dmenu+' can be added to \verb+\includemedia+ (see above). It creates context (right-click) menu entry `Get Current View' which outputs a complete \verb+VIEW+ section corresponding to the current view of the 3D object in the Reader, including camera position, an optional cross section, and all part and viewing options that can be modified via the 3D toolbar (option `\verb+3Dtoolbar+') or the context menu of the 3D object (entries `\emph{\sffamily Part Options}', `\emph{\sffamily Viewing Options}'). Hence, apart from tweaking one or another entry, there should no need for writing views files by hand.
+To facilitate the creation of a views file, option `\verb+3Dmenu+' can be added to \verb+\includemedia+ (see above). It creates context (right-click) menu entry `Get Current View' which outputs a complete \verb+VIEW+ section corresponding to the current view of the 3D object in the Reader, including camera position, an optional cross section, and all part and viewing options that can be modified via the 3D toolbar (option `\verb+3Dtoolbar+') or the context menu of the 3D object (entries `\emph{\sffamily Part Options}', `\emph{\sffamily Viewing Options}'). Hence, apart from tweaking one or another entry, there should be no need for writing views files by hand.
\begin{verbatim}
3Dplaytype=linear | oscillating
\end{verbatim}
@@ -357,13 +368,13 @@ add3Djscript=<another 3D JavaScript file>,
\end{verbatim}
Things like animation, lighting, background of 3D objects etc. may also be script driven. Every invocation of `\verb+add3Djscript+' associates another JavaScript file with the 3D object. Upon activation of the 3D object, the scripts are executed once in the order of their inclusion. Refer to the Acrobat 3D JavaScript Reference~\cite{jscript3D} for syntax details. The following 3D JavaScript loads an image file that was attached by `\verb+addresource=images/sunset.jpg+' and uses it as the scene background.
\begin{verbatim}
- sunset = new Image(new Resource('pdf://images/sunset.jpg'));
- reh = new RenderEventHandler();
- reh.onEvent = function(event) {
- runtime.removeEventHandler(this);
- event.canvas.background.image=sunset;
+ sunset = new Image(new Resource('pdf://images/sunset.jpg'));
+ reh = new RenderEventHandler();
+ reh.onEvent = function(event) {
+ runtime.removeEventHandler(this);
+ event.canvas.background.image=sunset;
}
- runtime.addEventHandler(reh);
+ runtime.addEventHandler(reh);
\end{verbatim}
\hypertarget{3dscripts}{}For convenience, subdirectory `javascript' of the `media9' installation contains three 3D JavaScript files which may come in handy at times: `animation.js' enables embedded keyframe animation in 3D files; `3Dspintool.js' enables the Spin tool of the 3D plugin for easier rotating the 3D object with the mouse; `asylabels.js' adds `billboard behaviour' to text labels in Asymptote generated PRC files for improved visibility, they always face the camera while dragging the 3D object with the mouse.
@@ -372,16 +383,17 @@ Things like animation, lighting, background of 3D objects etc. may also be scrip
\caption{Entries in a {\tt VIEW} section.}\label{tab:views}
\begin{tabular}[t]{p{0.24\linewidth}lp{0.4\linewidth}}\hline
key & type & remarks\\\hline\hline
- COO & three numbers & centre of orbit, see option `{\tt 3Dcoo}'\\
- C2C & three numbers & centre of orbit to camera vector, see option `{\tt 3Dc2c}'\\
- ROO & number & radius of orbit, see option `{\tt 3Droo}'\\
- C2W & 12 numbers & camera-to-world transformation matrix, see option `{\tt 3Dc2w}'\\
- AAC & number & camera aperture angle, see option `{\tt 3Daac}'\\
+ COO & three numbers & centre of orbit, see option `{\tt 3Dcoo}'\\
+ C2C & three numbers & centre of orbit to camera vector, see option `{\tt 3Dc2c}'\\
+ ROO & number & radius of orbit, see option `{\tt 3Droo}'\\
+ C2W & 12 numbers & camera-to-world transformation matrix, see option `{\tt 3Dc2w}'\\
+ AAC & number & camera aperture angle, see option `{\tt 3Daac}'\\
ORTHO & number (optional) & enables orthographic view, see option `{\tt 3Dortho}'\\
- ROLL & number & camera roll, see option `{\tt 3Droll}'\\
- BGCOLOR & three numbers & 3D scene background colour (RGB), see option `{\tt 3Dbg}'\\
- RENDERMODE & string & render mode of the 3D object, see option `{\tt 3Drender}'\\
+ ROLL & number & camera roll, see option `{\tt 3Droll}'\\
+ BGCOLOR & three numbers & 3D scene background colour (RGB), see option `{\tt 3Dbg}'\\
+ RENDERMODE & string & render mode of the 3D object, see option `{\tt 3Drender}'\\
LIGHTS & string & lighting scheme, see option `{\tt 3Dlights}'\\
+ PARTSATTRS & string & allowed values are `{\tt keep}' and `{\tt restore}'; decides on whether to restore or not original part attributes before applying new ones from this view; see option `{\tt 3Dpartsattrs}'\\
PART\,\,(sub-sec\-tion) & string & part name as in the model tree; optional if a UTF16NAME entry is present in the sub-section opened by a PART keyword, otherwise required; see Table~\ref{tab:parts} for list of possible entries\\
CROSSSECT~(sub-section) & -- & see Table~\ref{tab:crosss} for list of possible entries\\
\hline
@@ -413,7 +425,7 @@ Things like animation, lighting, background of 3D objects etc. may also be scrip
\end{tabular}
\end{table}
-\clearpage
+%\clearpage
\section[Embedding Flash, video and sound (with examples)]{Embedding Flash, video and sound}
A YouTube video clip, as shown in Fig.~\ref{alien}, may serve as a basic example of loading Flash content from a URL to be displayed in an embedded fashion in a PDF document. Indeed, a YouTube clip is nothing more than a small SWF file which loads a video stream and other necessary resources, such as user controls and a player skin from a remote server. It can be configured via ActionScript variables, to play several videos in a row, to play a video in a loop etc. Player parameters are documented on \url{http://code.google.com/apis/youtube/player_parameters.html} and can be passed to the player using either the `\verb+flashvars+' option, as in the example, or appended to the URL string after the video ID. A question mark `\verb+?+' must be put between the video ID and the parameter string. Some of the documented parameters, such as `\verb+rel+', seem to have an effect only if they are passed as part of the URL.
@@ -428,7 +440,7 @@ A YouTube video clip, as shown in Fig.~\ref{alien}, may serve as a basic example
&autohide=1 % controlbar autohide
&showinfo=0 % no title and other info before start
&rel=0 % no related videos after end
- },
+ },
url % Flash loaded from URL
]{}{http://www.youtube.com/v/Mdc3o7wOwNA?rel=0}
\end{Verbatim}
@@ -441,7 +453,7 @@ A YouTube video clip, as shown in Fig.~\ref{alien}, may serve as a basic example
&autohide=1 % controlbar autohide
&showinfo=0 % no title and other info before start
&rel=0 % no related videos after end
- },
+ },
url % Flash loaded from URL
]{}{http://www.youtube.com/v/Mdc3o7wOwNA?rel=0}
\caption{A YouTube video as an example of a Flash application loaded from a URL.}\label{alien}
@@ -449,7 +461,7 @@ A YouTube video clip, as shown in Fig.~\ref{alien}, may serve as a basic example
Video and sound files are always loaded and then played by a media player application. Three players are installed along with the `media9.sty' package file: two simple players, `VPlayer.swf' for video and `APlayer.swf' for sound, and a fully blown one, `StrobeMediaPlayback.swf', with some fixes to improve its usability. The simple ones are `chromeless' players, that is, they do not have user controls. Minimal interactivity for play, pause and resume is still provided via left mouse button press and release. They were compiled, using the free Adobe Flex SDK~\cite{flex}, from XML files which reside in the \verb+doc/+ folder of the package installation. For `StrobeMediaPlayback.swf', only a patch file is included, as the sources can be downloaded elsewhere.
-The included version of `StrobeMediaPlayback.swf' is preferably to be used, as it is smaller than `VPlayer.swf' in terms of file size and it provides user controls. The improvements of `StrobeMediaPlayback.swf' in comparision to the original version on SourceForge.net are
+The improvements of `StrobeMediaPlayback.swf' in comparision to the original version on SourceForge.net are
\begin{itemize}
\item fix: video could not be restarted after end of playback if ActionScript variable `{\tt autoRewind}' is set to `{\tt false}'
\item new: first frame of video is shown as default poster instead of black stage
@@ -460,7 +472,9 @@ There is no need to copy the installed players into the directory of the documen
Like YouTube videos, media players are configured via ActionScript variables which are passed using option `\verb+flashvars+'. Table~\ref{playerparams} lists parameters available for `VPlayer.swf' and `APlayer.swf', table~\ref{smpparams} for `StrobeMediaPlayback.swf'.
-Playback of an embedded video is shown in Fig.~\ref{video}a. Besides embedded files, also video streamed from remote servers via HTTP and RTMP protocols is supported, as shown in Fig.~\ref{video}b.
+Playback of embedded video files is shown in Fig.~\ref{videoa}. Besides embedded files, also video streamed from remote servers via HTTP and RTMP protocols is supported, as shown in Fig.~\ref{videob}.
+
+`VPlayer.swf' and `APlayer.swf' expose a number of ActionScript functions to the JavaScript engine of Adobe Reader, allowing for playback control of media through PDF interactive forms and various trigger events. The functions and their calling convention are listed in Table~\ref{AVPlayerMethods}. An example of playing and pausing a video clip and setting the video source via interactive push buttons is given in Fig.~\ref{videoa}.
\begin{table}[p]
\centering
@@ -470,6 +484,7 @@ parameter & description\\\hline\hline
{\tt source=<file path or URL>} & (required) path to embedded media file (see option `{\tt addresource}'), or URL (http, rtmp) to online media file\\
{\tt autoPlay=true|false} & if {\tt=true}, automatically starts playback after activation (see option `{\tt activation})'\\
{\tt loop=true|false} & if {\tt=true}, media is played in a loop\\
+{\tt scaleMode=letterbox|none| \phantom{.}\hfill{}stretch|zoom} & default: {\tt stretch}; determines how to scale the video in order to fit into player\\
{\tt volume=<value between 0.0 \phantom{.}\hfill{}and 1.0>} & sets volume of the sound\\
{\tt balance=<value between \phantom{xxxx} \phantom{.}\hfill{}-1.0 and 1.0>} & (APlayer.swf only) sets balance of sound speakers\\\hline
\end{tabular}
@@ -477,6 +492,22 @@ parameter & description\\\hline\hline
\begin{table}[p]
\centering
+\caption{Exposed ActionScript functions of media players `VPlayer.swf' and `APlayer.swf', that can be called from JavaScript using the `{\tt callAS}' method of the `{\tt AnnotRichMedia}' JavaScript object. Calling convention: \hbox to \linewidth {\hss\tt <RMA reference>.callAS('<function>' [,'<argument>']);\hss} Function name and its argument must be given as quoted strings. See~\cite{jscript} for further information.}\label{AVPlayerMethods}
+\begin{tabular}[t]{llp{0.5\linewidth}}\hline
+function & argument &description\\\hline\hline
+{\tt play} & & play media\\
+{\tt pause} & & pause media\\
+{\tt playPause} & & toggle between play and pause\\
+{\tt setSource} & string & load another media file (path to file, embedded using option `{\tt addresource}', or URL)\\
+{\tt seek} & number & move the play location to a time offset from the beginning of the media; argument measured in seconds\\
+{\tt rewind} & & rewind media to the beginning (without pausing it)\\
+{\tt volume} & number between 0 and 1 & set volume level\\
+{\tt mute} & & mute or unmute (toggle) the audio of the media\\\hline
+\end{tabular}
+\end{table}
+
+\begin{table}[p]
+\centering
\caption{Parameters (ActionScript variables) for `StrobeMediaPlayback.swf' shipping with media9. Parameters are passed as a `{\tt\&}'-separated string using `{\tt flashvars}' option.}\label{smpparams}
\begin{tabular}[t]{p{0.4\linewidth}p{0.5\linewidth}}\hline
parameter & description\\\hline\hline
@@ -501,26 +532,60 @@ parameter & description\\\hline\hline
\centering
\begin{Verbatim}
\includemedia[
+ label=some_dice, % defines JavaScript object annotRM['some_dice']
width=0.4\linewidth,height=0.3\linewidth,
activate=pageopen,
- addresource=files/random.mp4,
+ addresource=files/random.mp4, %two video files
+ addresource=files/cube.mp4,
flashvars={
source=files/random.mp4 % same path as in addresource!
&loop=true % loop video
- }
+ &scaleMode=letterbox % preserve aspect ratio while scaling the video
+ }
]{}{VPlayer.swf}
+
+\PushButton[ %requires package `hyperref'
+ onclick={
+ annotRM['some_dice'].activated=true;
+ annotRM['some_dice'].callAS('playPause');
+ }
+]{\fbox{Play/Pause}}
+\PushButton[
+ onclick={
+ annotRM['some_dice'].activated=true;
+ annotRM['some_dice'].callAS('setSource', 'files/random.mp4');
+ }
+]{\fbox{random.mp4}}
+\PushButton[
+ onclick={
+ annotRM['some_dice'].activated=true;
+ annotRM['some_dice'].callAS('setSource', 'files/cube.mp4');
+ }
+]{\fbox{cube.mp4}}
\end{Verbatim}
\vspace{1ex}
-\makebox[\linewidth]{a)\hfill\includemedia[
+\makebox[\linewidth]{\hfill\includemedia[
+ label=some_dice,
width=0.6\linewidth,height=0.45\linewidth,
activate=pageopen,
- addresource=files/random.mp4, %embeds video file
+ addresource=files/random.mp4,
+ addresource=files/cube.mp4,
flashvars={
- source=files/random.mp4 % same path as in addresource!
- &loop=true % loop video
- }
+ source=files/random.mp4
+ &loop=true
+ &scaleMode=letterbox
+ }
]{}{VPlayer.swf}\hfill}
-\vskip 1ex
+\makebox[\linewidth]{\hfill%
+ \PushButton[onclick={annotRM['some_dice'].activated=true;annotRM['some_dice'].callAS('playPause');}]{\fbox{\strut Play/Pause}}
+ \PushButton[onclick={annotRM['some_dice'].activated=true;annotRM['some_dice'].callAS('setSource', 'files/random.mp4');}]{\fbox{\strut random.mp4}}
+ \PushButton[onclick={annotRM['some_dice'].activated=true;annotRM['some_dice'].callAS('setSource', 'files/cube.mp4');}]{\fbox{\strut cube.mp4}}
+\hfill}
+\caption{Example of playing back two different embedded MP4 video files in the same video player instance. The player, `VPlayer.swf', is also embedded in the PDF. Exposed ActionScript functions `{\tt playPause}' and `{\tt setSource}' of `VPlayer.swf' (Table~\ref{AVPlayerMethods}) are used to set-up the JavaScript actions of interactive push buttons.}\label{videoa}
+\end{figure}
+
+\begin{figure}
+\centering
\begin{Verbatim}
\includemedia[
width=0.6\linewidth,height=0.3375\linewidth, % 16:9
@@ -533,7 +598,7 @@ parameter & description\\\hline\hline
]{}{StrobeMediaPlayback.swf}
\end{Verbatim}
\vspace{1ex}
-\makebox[\linewidth]{b)\hfill\includemedia[
+\makebox[\linewidth]{\hfill\includemedia[
width=0.6\linewidth,height=0.3375\linewidth,
activate=pageopen,
flashvars={
@@ -542,7 +607,7 @@ parameter & description\\\hline\hline
&scaleMode=stretch
}
]{}{StrobeMediaPlayback.swf}\hfill}
-\caption{Example of (a) an embedded MP4 video file and (b) streamed video from an RTMP server. First example uses `VPlayer.swf', the second one `StrobeMediaPlayBack.swf'. Both are physically embedded in the PDF.}\label{video}
+\caption{Example of video streamed from an RTMP server. This example uses media player `StrobeMediaPlayBack.swf', physically embedded in the PDF.}\label{videob}
\end{figure}
%\enlargethispage{2ex}