From 502b3247f7162d722b01b5f0cb89f6c27c12256d Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 27 Jun 2014 22:03:47 +0000 Subject: media9 (27jun14) git-svn-id: svn://tug.org/texlive/trunk@34456 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/media9/ChangeLog | 9 + .../doc/latex/media9/files/players/APlayer.mxml | 54 ++-- .../doc/latex/media9/files/players/APlayer9.mxml | 104 ++++--- .../doc/latex/media9/files/players/VPlayer.mxml | 28 +- .../doc/latex/media9/files/players/VPlayer9.mxml | 46 ++- Master/texmf-dist/doc/latex/media9/media9.pdf | Bin 3323616 -> 3326799 bytes Master/texmf-dist/doc/latex/media9/media9.tex | 64 +++-- Master/texmf-dist/tex/latex/media9/media9.sty | 318 ++++++++++++--------- .../tex/latex/media9/players/APlayer.swf | Bin 352533 -> 351961 bytes .../tex/latex/media9/players/APlayer9.swf | Bin 205585 -> 205983 bytes .../tex/latex/media9/players/VPlayer.swf | Bin 509312 -> 509501 bytes .../tex/latex/media9/players/VPlayer9.swf | Bin 218899 -> 219253 bytes 12 files changed, 410 insertions(+), 213 deletions(-) diff --git a/Master/texmf-dist/doc/latex/media9/ChangeLog b/Master/texmf-dist/doc/latex/media9/ChangeLog index 824633d925d..814c551f827 100644 --- a/Master/texmf-dist/doc/latex/media9/ChangeLog +++ b/Master/texmf-dist/doc/latex/media9/ChangeLog @@ -1,3 +1,12 @@ +2014-06-25 + * v0.45 + * fix: transparency in media button faces drawn with TikZ/PGF didn't work when + using the dvipdfmx/xetex driver + * new: [AV]Player ActionScript methods `play' and `pause' take optional time + offsets, allowing for playing portions of the media file + * Change: `depth' option deprecated and ignored if used, added `totalheight' + and `keepaspectratio' options + 2014-06-04 * v0.44 * fix: prevent the play button from being printed to paper or exported to 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 78503bc4695..30ae5de9229 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 @@ - + @@ -64,7 +64,9 @@ private var id3:ID3Info; private var sndCh:SoundChannel; private var sndTr:SoundTransform; - private var playResumePosition:Number = 0; + private var playResumePos:Number = 0; + private var pauseAtPos:Number = -1; + private var toBePaused:Boolean = false; private var plyng:Boolean = false; private var muted:Boolean = false; private var lastVol:Number; @@ -117,12 +119,12 @@ break; case 36: //home pause(); - playResumePosition=(0); + playResumePos=(0); break; case 35: //end if(playProgress.indeterminate) break; pause(); - playResumePosition=(snd.length); + playResumePos=(snd.length); break; case 37: //<-- fadeEffect.end(); @@ -137,11 +139,11 @@ if(plyng) curTime=sndCh.position; else - curTime=playResumePosition; + curTime=playResumePos; } keyPressed=true; - playResumePosition=Math.max(0,curTime-deltaSeek); - if(plyng) seek(playResumePosition/1000); + playResumePos=Math.max(0,curTime-deltaSeek); + if(plyng) seek(playResumePos/1000); deltaSeek*=1.1; break; case 39: //--> @@ -157,11 +159,11 @@ if(plyng) curTime=sndCh.position; else - curTime=playResumePosition; + curTime=playResumePos; } keyPressed=true; - playResumePosition=Math.min(snd.length-10,curTime+deltaSeek); - seek(playResumePosition/1000); + playResumePos=Math.min(snd.length-10,curTime+deltaSeek); + seek(playResumePos/1000); deltaSeek*=1.1; break; case 38: @@ -233,17 +235,19 @@ private function loadPolicy(p:String):void {policy=p;} - private function play():void { + private function play(p:Number=-1):void { + if(p>=0) seek(p); if(plyng) return; - try{sndCh = snd.play(playResumePosition, 0, sndTr);} + try{sndCh = snd.play(playResumePos, 0, sndTr);} catch(e:Error){Alert.show(e.message,'Error');} sndCh.addEventListener(Event.SOUND_COMPLETE, onSoundComplete); plyng = true; } - private function pause():void { + private function pause(p:Number=-1):void { + if(p>=0){pauseAtPos=p*1000;return;} if(!plyng) return; - playResumePosition = sndCh.position; + playResumePos = sndCh.position; sndCh.stop(); plyng = false; } @@ -253,7 +257,7 @@ } private function seek(p:Number):void { - playResumePosition = p*1000; + playResumePos = p*1000; if(!plyng) return; sndCh.stop(); plyng = false; @@ -288,7 +292,7 @@ } private function currentTime():Number { - return sndCh.position/1000; + return sndCh.position/1000; } private function playing():Boolean { @@ -322,7 +326,7 @@ private function onSoundComplete(e:Event):void { plyng = false; - playResumePosition = 0; + playResumePos = 0; if(loop) play(); } @@ -340,8 +344,8 @@ playProgress.setProgress(sndCh.position,snd.length); caption.text=formatLabel(sndCh.position); } else { - playProgress.setProgress(playResumePosition,snd.length); - caption.text=formatLabel(playResumePosition); + playProgress.setProgress(playResumePos,snd.length); + caption.text=formatLabel(playResumePos); } }else{ if(plyng) { @@ -349,9 +353,19 @@ caption.text=formatLabel(sndCh.position); } else { playProgress.setProgress(snd.bytesLoaded,snd.bytesTotal); - caption.text=formatLabel(playResumePosition); + caption.text=formatLabel(playResumePos); } } + if(plyng&&pauseAtPos>=0&&sndCh.position=0&& + sndCh.position>=pauseAtPos&&toBePaused + ){ + pause(); + pauseAtPos=-1; + toBePaused=false; + } } private function onID3Info(e:Event):void {id3 = e.target.id3;} diff --git a/Master/texmf-dist/doc/latex/media9/files/players/APlayer9.mxml b/Master/texmf-dist/doc/latex/media9/files/players/APlayer9.mxml index 35a154ae3fc..1a80f98c921 100644 --- a/Master/texmf-dist/doc/latex/media9/files/players/APlayer9.mxml +++ b/Master/texmf-dist/doc/latex/media9/files/players/APlayer9.mxml @@ -4,7 +4,7 @@ - + @@ -50,13 +50,15 @@ private var id3:ID3Info; private var sndCh:SoundChannel; private var sndTr:SoundTransform; - private var playResumePosition:Number = 0; - private var playing:Boolean = false; + private var playResumePos:Number = 0; + private var pauseAtPos:Number = -1; + private var toBePaused:Boolean = false; + private var plyng:Boolean = false; private var muted:Boolean = false; private var lastVol:Number; private var deltaSeek:Number; - private var currentTime:Number; + private var curTime:Number; private var keyPressed:Boolean=false; private var mouseIsOver:Boolean=false; @@ -104,12 +106,12 @@ break; case 36: //home pause(); - playResumePosition=(0); + playResumePos=(0); break; case 35: //end if(playProgress.indeterminate) break; pause(); - playResumePosition=(snd.length); + playResumePos=(snd.length); break; case 37: //<-- fadeEffect.end(); @@ -122,14 +124,14 @@ } if(!keyPressed){ deltaSeek=Math.max(100,snd.length/10000); - if(playing) - currentTime=sndCh.position; + if(plyng) + curTime=sndCh.position; else - currentTime=playResumePosition; + curTime=playResumePos; } keyPressed=true; - playResumePosition=Math.max(0,currentTime-deltaSeek); - if(playing) seek(playResumePosition/1000); + playResumePos=Math.max(0,curTime-deltaSeek); + if(plyng) seek(playResumePos/1000); deltaSeek*=1.1; break; case 39: //--> @@ -143,14 +145,14 @@ } if(!keyPressed){ deltaSeek=Math.max(100,snd.length/10000); - if(playing) - currentTime=sndCh.position; + if(plyng) + curTime=sndCh.position; else - currentTime=playResumePosition; + curTime=playResumePos; } keyPressed=true; - playResumePosition=Math.min(snd.length-10,currentTime+deltaSeek); - seek(playResumePosition/1000); + playResumePos=Math.min(snd.length-10,curTime+deltaSeek); + seek(playResumePos/1000); deltaSeek*=1.1; break; case 38: @@ -222,30 +224,32 @@ private function loadPolicy(p:String):void {policy=p;} - private function play():void { - if(playing) return; - try{sndCh = snd.play(playResumePosition, 0, sndTr);} + private function play(p:Number=-1):void { + if(p>=0) seek(p); + if(plyng) return; + try{sndCh = snd.play(playResumePos, 0, sndTr);} catch(e:Error){Alert.show(e.message,'Error');} sndCh.addEventListener(Event.SOUND_COMPLETE, onSoundComplete); - playing = true; + plyng = true; } - private function pause():void { - if(!playing) return; - playResumePosition = sndCh.position; + private function pause(p:Number=-1):void { + if(p>=0){pauseAtPos=p*1000;return;} + if(!plyng) return; + playResumePos = sndCh.position; sndCh.stop(); - playing = false; + plyng = false; } private function playPause():void { - if(playing) pause(); else play(); + if(plyng) pause(); else play(); } private function seek(p:Number):void { - playResumePosition = p*1000; - if(!playing) return; + playResumePos = p*1000; + if(!plyng) return; sndCh.stop(); - playing = false; + plyng = false; play(); } @@ -276,6 +280,22 @@ sndCh.soundTransform=sndTr; } + private function currentTime():Number { + return sndCh.position/1000; + } + + private function playing():Boolean { + return plyng; + } + + private function duration():Number { + return snd.length/1000; + } + + private function ismuted():Boolean { + return muted; + } + private function initCallBacks():void { ExternalInterface.addCallback("play", play); ExternalInterface.addCallback("pause", pause); @@ -287,11 +307,15 @@ ExternalInterface.addCallback("mute", mute); ExternalInterface.addCallback("setSource", setSource); ExternalInterface.addCallback("loadPolicy", loadPolicy); + ExternalInterface.addCallback("currentTime", currentTime); + ExternalInterface.addCallback("duration", duration); + ExternalInterface.addCallback("playing", playing); + ExternalInterface.addCallback("muted", ismuted); } private function onSoundComplete(e:Event):void { - playing = false; - playResumePosition = 0; + plyng = false; + playResumePos = 0; if(loop) play(); } @@ -305,22 +329,32 @@ private function onEnterFrame(e:Event):void { if(!playProgress.indeterminate) { - if(playing) { + if(plyng) { playProgress.setProgress(sndCh.position,snd.length); caption.text=formatLabel(sndCh.position); } else { - playProgress.setProgress(playResumePosition,snd.length); - caption.text=formatLabel(playResumePosition); + playProgress.setProgress(playResumePos,snd.length); + caption.text=formatLabel(playResumePos); } }else{ - if(playing) { + if(plyng) { playProgress.setProgress(Math.random(),1); caption.text=formatLabel(sndCh.position); } else { playProgress.setProgress(snd.bytesLoaded,snd.bytesTotal); - caption.text=formatLabel(playResumePosition); + caption.text=formatLabel(playResumePos); } } + if(plyng&&pauseAtPos>=0&&sndCh.position=0&& + sndCh.position>=pauseAtPos&&toBePaused + ){ + pause(); + pauseAtPos=-1; + toBePaused=false; + } } private function onID3Info(e:Event):void {id3 = e.target.id3;} 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 a5f05bbb425..7d73ce43b7d 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 @@ - + @@ -57,6 +57,8 @@ private var curTime:Number; private var newPos:Number; private var keyPressed:Boolean=false; + private var pauseAtPos:Number = -1; + private var toBePaused:Boolean = false; import mx.core.FlexGlobals; private function initialise(flashVars:Object):void { @@ -155,11 +157,26 @@ if(stepping&&vidDisp.playing){vidDisp.pause();} } - private function play():void { - if(vidComplete){vidDisp.seek(0);}vidDisp.play(); + private function onCurrentTimeChange(e:Event):void { + if(vidDisp.playing&&pauseAtPos>=0&&vidDisp.currentTime=0&& + vidDisp.currentTime>=pauseAtPos&&toBePaused + ){ + pause(); + pauseAtPos=-1; + toBePaused=false; + } + } + + private function play(p:Number=-1):void { + if(p>=0) seek(p); + if(vidComplete){seek(0);}vidDisp.play(); } - private function pause():void { + private function pause(p:Number=-1):void { + if(p>=0){pauseAtPos=p;return;} vidDisp.pause(); } @@ -262,12 +279,13 @@ id="vidDisp" width="100%" height="100%" scaleMode="{scaleMode}" source="{source}" volume="{vol}" - autoPlay="{autoPlay}" autoRewind="{autoRewind}" loop="{loop}" + autoPlay="{autoPlay}" autoRewind="{autoRewind}" loop="{loop}" mouseDown="if(stepping){vidDisp.play();}else{vidDisp.pause();}this.setFocus();" mouseUp="if(vidComplete) vidDisp.seek(0);if(!stepping){vidDisp.play();}" mediaPlayerStateChange="onStateChange(event);" complete="vidComplete=true;" durationChange="vidDisp.seek(0);" + currentTimeChange="onCurrentTimeChange(event);" /> - + @@ -46,6 +46,8 @@ private var keyPressed:Boolean=false; private var muted:Boolean=false; private var lastVolume:Number; + private var pauseAtPos:Number = -1; + private var toBePaused:Boolean = false; import flash.external.*; private function initialise(flashVars:Object):void { @@ -143,11 +145,26 @@ if(stepping&&vidDisp.playing){vidDisp.pause();} } - private function play():void { - if(vidComplete){vidDisp.playheadTime=0;}vidDisp.play(); + private function onPlayheadUpdate(e:Event):void { + if(vidDisp.playing&&pauseAtPos>=0&&vidDisp.playheadTime=0&& + vidDisp.playheadTime>=pauseAtPos&&toBePaused + ){ + pause(); + pauseAtPos=-1; + toBePaused=false; + } + } + + private function play(p:Number=-1):void { + if(p>=0) seek(p); + if(vidComplete){seek(0);}vidDisp.play(); } - private function pause():void { + private function pause(p:Number=-1):void { + if(p>=0){pauseAtPos=p;return;} vidDisp.pause(); } @@ -206,6 +223,22 @@ return fmtd; } + private function currentTime():Number { + return vidDisp.playheadTime; + } + + private function playing():Boolean { + return vidDisp.playing; + } + + private function duration():Number { + return vidDisp.totalTime; + } + + private function ismuted():Boolean { + return muted; + } + private function init():void { this.setFocus(); this.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); @@ -220,6 +253,10 @@ ExternalInterface.addCallback("mute", mute); ExternalInterface.addCallback("setSource", setSource); ExternalInterface.addCallback("stepping", step); + ExternalInterface.addCallback("currentTime", currentTime); + ExternalInterface.addCallback("duration", duration); + ExternalInterface.addCallback("playing", playing); + ExternalInterface.addCallback("muted", ismuted); } ]]> @@ -239,6 +276,7 @@ stateChange="onStateChange(event);" complete="vidComplete=true;" rewind="vidDisp.play();" + playheadUpdate="onPlayheadUpdate(event);" /> +, i Argument \verb++ defines the size of the rectangular region of the document page in which the media will be displayed. Moreover, \verb++ will be shown in case the media has not been activated. %(Internally, \verb++ is put into a \LaTeX{} box, which is used as the appearance of the PDF annotation, i.\,e. the interactive region created by \verb+\includemedia+, in PDF specification parlance.) -\verb++ can be anything that \LaTeX{} can typeset, such as an \verb+\includegraphics+ command serving as a poster image, a PGF/TikZ/PSTricks inline graphics or just ordinary text. Alternatively, \verb++ can be left blank in which case the size of the media rectangle should be set with options `\verb+width+', `\verb+height+' and optionally with `\verb+depth+'. If sizing options `\verb+width+' and `\verb+height+' are given \emph{together} with \verb++, \verb++ will be shrunk or stretched to fit exactly into the rectangle defined by the options, possibly changing the original aspect ratio of the poster text. On the other hand, if only one of `\verb+width+' or `\verb+height+' is given, the other dimension of \verb++ is scaled such that the original aspect ratio is preserved. +\verb++ can be anything that \LaTeX{} can typeset, such as an \verb+\includegraphics+ command serving as a poster image, a PGF/TikZ/PSTricks inline graphics or just ordinary text. Alternatively, \verb++ can be left blank in which case the size of the media rectangle should be set with options `\verb+width+' and `\verb+height+'. If a non-zero size \verb++ was provided, it can be resized using any combination of options `\verb+width+', `\verb+height+' or `\verb+totalheight+', `\verb+keepaspectratio+' and `\verb+scale+'. A list of directories where \TeX{} searches for media and resource files can be set-up by means of \begin{verbatim} @@ -202,17 +202,17 @@ The following section explains all command options provided. They are passed to \subsection{Command options} A subset of the command options (see Sect. \ref{pkguse}) can also be used as package options, which lets them apply to all embedded media. Some of the options listed here are meaningful only for a specific media type (either Flash or 3D), which will be noted explicitly if not obvious. Dedicated sections covering Flash, video and sound as well as 3D inclusion will follow later on in this document. -\begin{verbatim} -width=, -height=, -depth= -\end{verbatim} -Resize the media playback area, overriding the original dimensions of the {\tt} 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++. 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++. \begin{verbatim} label=