summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml')
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/players/VPlayer.mxml291
1 files changed, 198 insertions, 93 deletions
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 1c71c751c08..be441e61dce 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 20120425 -->
+<!-- version 20121002 -->
<!-- -->
<!-- -->
<!-- The free Adobe Flex 4 SDK is required to compile -->
@@ -37,110 +37,215 @@
<!-- -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:mx="library://ns.adobe.com/flex/mx"
- preinitialize="initialise(FlexGlobals.topLevelApplication.parameters);"
- creationComplete="initCallBacks();"
+ xmlns:s="library://ns.adobe.com/flex/spark"
+ xmlns:mx="library://ns.adobe.com/flex/mx"
+ preinitialize="initialise(FlexGlobals.topLevelApplication.parameters);"
+ creationComplete="init();"
>
- <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 vol:Number=0.75;
- private var vidComplete:Boolean=false;
-
- import mx.core.FlexGlobals;
- 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){vol=Number(flashVars.volume)}
- if(flashVars.scaleMode){scaleMode=flashVars.scaleMode}
- }
+ <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 vol:Number=0.75;
+ private var vidComplete:Boolean=false;
+ private var deltaSeek:Number;
+ private var currentTime:Number;
+ private var newPos:Number;
+ private var keyPressed:Boolean=false;
- import flash.events.ProgressEvent;
- private function progressHandler(event:ProgressEvent):void {
- if (event.bytesTotal) event.target.visible=true;
- else event.target.visible=false;
- }
+ import mx.core.FlexGlobals;
+ 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){vol=Number(flashVars.volume)}
+ if(flashVars.scaleMode){scaleMode=flashVars.scaleMode}
+ }
- 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');
- }
+ import flash.events.ProgressEvent;
+ private function progressHandler(event:ProgressEvent):void {
+ if (event.bytesTotal) event.target.visible=true;
+ else event.target.visible=false;
+ }
- private function play():void {
- if(vidComplete){vidDisp.seek(0);}vidDisp.play();
- }
+ 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 pause():void {
+ import flash.events.KeyboardEvent;
+ private function keyDnHnd(e:KeyboardEvent):void {
+ switch(e.keyCode) {
+ case 32: //space bar
+ playPause();
+ break;
+ case 36: //home
+ vidDisp.pause();
+ vidDisp.seek(0);
+ break;
+ case 35: //end
+ if(vidDisp.bytesTotal){
vidDisp.pause();
+ vidDisp.seek(vidDisp.duration-0.1);
}
-
- private function playPause():void {
- if(vidDisp.playing) vidDisp.pause(); else vidDisp.play();
+ break;
+ case 37: //<--
+ fadeEffect.end();
+ playProgress.alpha=0.5;
+ playProgress.visible=true;
+ if(!keyPressed){
+ deltaSeek=Math.max(1,vidDisp.duration/1000);
+ currentTime=vidDisp.currentTime;
}
-
- private function seek(p:Number):void {
- vidDisp.seek(p);
+ keyPressed=true;
+ newPos=Math.max(0,currentTime-deltaSeek);
+ playProgress.setProgress(newPos,vidDisp.duration);
+ playProgress.label=formatTime(newPos);
+ vidDisp.seek(newPos);
+ deltaSeek*=1.1;
+ break;
+ case 39: //-->
+ fadeEffect.end();
+ playProgress.alpha=0.5;
+ playProgress.visible=true;
+ if(!keyPressed){
+ deltaSeek=Math.max(1,vidDisp.duration/1000);
+ currentTime=vidDisp.currentTime;
}
+ keyPressed=true;
+ newPos=Math.min(vidDisp.duration-0.1,currentTime+deltaSeek);
+ playProgress.setProgress(newPos,vidDisp.duration);
+ playProgress.label=formatTime(newPos);
+ vidDisp.seek(newPos);
+ deltaSeek*=1.1;
+ break;
+ case 38:
+ vol=Math.min(1,vol+0.025);
+ volume(vol);
+ break;
+ case 40:
+ vol=Math.max(0,vol-0.025);
+ volume(vol);
+ break;
+ default:
+ if(e.charCode==109) mute(); //`m'
+ }
+ }
- private function rewind():void {
- vidDisp.seek(0);
- }
+ private function keyUpHnd(e:KeyboardEvent):void {
+ switch(e.keyCode) {
+ case 37: //<--
+ case 39: //-->
+ deltaSeek=Math.max(1,vidDisp.duration/1000);
+ keyPressed=false;
+ fadeEffect.play();
+ break;
+ }
+ }
- private function volume(v:Number):void {
- vidDisp.volume = v;
- }
+ private function play():void {
+ if(vidComplete){vidDisp.seek(0);}vidDisp.play();
+ }
- private function mute():void {
- if(vidDisp.muted) {
- vidDisp.muted=false;
- if (vidDisp.volume==0) volume(0.75);
- }
- else {
- vidDisp.muted=true;
- }
- }
+ private function pause():void {
+ vidDisp.pause();
+ }
- private function setSource(s:Object):void {
- vidDisp.source = s;
- }
+ private function playPause():void {
+ if(vidDisp.playing) vidDisp.pause(); else vidDisp.play();
+ }
- 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="{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)"
- />
+ private function seek(p:Number):void {
+ vidDisp.seek(p);
+ }
+
+ private function rewind():void {
+ vidDisp.seek(0);
+ }
+
+ private function volume(v:Number):void {
+ vidDisp.muted=false;
+ 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 formatTime(s:Number):String {
+ var hrs:Number = Math.floor(s / 3600);
+ var min:Number = Math.floor(s / 60 % 60);
+ var sec:Number = Math.floor(s % 60);
+
+ var fmtd:String='';
+
+ if (hrs>0) fmtd = String(hrs)+':';
+
+ if (hrs>0 && min <10) fmtd+='0';
+ fmtd += String(min)+':';
+
+ if (sec<10) fmtd+='0';
+ fmtd += String(sec);
+
+ return fmtd;
+ }
+
+ private function init():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);
+ this.setFocus();
+ this.addEventListener(KeyboardEvent.KEY_DOWN, keyDnHnd);
+ this.addEventListener(KeyboardEvent.KEY_UP, keyUpHnd);
+ }
+ ]]>
+ </fx:Script>
+
+ <fx:Declarations>
+ <s:Fade id="fadeEffect" target="{playProgress}" alphaFrom="0.5" alphaTo="0" duration="2000"/>
+ </fx:Declarations>
+
+ <s:VideoDisplay
+ id="vidDisp"
+ width="100%" height="100%" scaleMode="{scaleMode}"
+ source="{source}" volume="{vol}"
+ autoPlay="{autoPlay}" autoRewind="false" loop="{loop}"
+ mouseDown="vidDisp.pause();this.setFocus();"
+ 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="100%" mode="polled" source="vidDisp"
+ horizontalCenter="0" bottom="0" labelPlacement="center"
+ id="loadingProgress" alpha="0.5"
+ complete="loadingProgress.visible=false;"
+ progress="progressHandler(event)"
+ />
+ <mx:ProgressBar width="100%" mode="manual"
+ horizontalCenter="0" bottom="0" labelPlacement="center"
+ id="playProgress" alpha="0.5"
+ visible="false"
+ />
</s:Application>