summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/media9/files/players/APlayer9.mxml
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/doc/latex/media9/files/players/APlayer9.mxml')
-rw-r--r--Master/texmf-dist/doc/latex/media9/files/players/APlayer9.mxml104
1 files changed, 69 insertions, 35 deletions
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 @@
<!-- a FlashPlayer-9 compatible component for playing -->
<!-- MP3 audio files and streams. -->
<!-- -->
-<!-- version 20131114 -->
+<!-- version 20140625 -->
<!-- -->
<!-- Copyright (C) 2012-today Alexander Grahn -->
<!-- -->
@@ -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<pauseAtPos)
+ toBePaused=true;
+ if(
+ plyng&&pauseAtPos>=0&&
+ sndCh.position>=pauseAtPos&&toBePaused
+ ){
+ pause();
+ pauseAtPos=-1;
+ toBePaused=false;
+ }
}
private function onID3Info(e:Event):void {id3 = e.target.id3;}