diff options
Diffstat (limited to 'Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml')
-rw-r--r-- | Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml | 93 |
1 files changed, 43 insertions, 50 deletions
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 09783ab38af..1822f9b82be 100644 --- a/Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml +++ b/Master/texmf-dist/doc/latex/media9/files/players/APlayer.mxml @@ -1,16 +1,16 @@ <?xml version="1.0"?> <!-- --> -<!-- Adobe Flex 4 source file of APlayer.swf, --> +<!-- Apache Flex 4 source file of APlayer.swf, --> <!-- a FlashPlayer-10 compatible component for playing --> <!-- MP3 audio files and streams. --> <!-- --> -<!-- version 20130320 --> +<!-- version 20130606 --> <!-- --> <!-- --> -<!-- The free Adobe Flex 4 SDK is required to compile --> +<!-- The free Apache Flex 4 SDK is required to compile --> <!-- this file. Get it from --> <!-- --> -<!-- http://www.adobe.com/products/flex/ --> +<!-- http://flex.apache.org/download-binaries.html --> <!-- --> <!-- and run --> <!-- --> @@ -19,7 +19,7 @@ <!-- on the command line. --> <!-- --> <!-- --> -<!-- Copyright (C) 2012 Alexander Grahn --> +<!-- Copyright (C) 2012-today Alexander Grahn --> <!-- --> <!-- This work may be distributed and/or modified under the --> <!-- conditions of the LaTeX Project Public License, either --> @@ -40,7 +40,7 @@ xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" preinitialize="initialise(FlexGlobals.topLevelApplication.parameters);" - applicationComplete="initSound();addeventlisteners(); + applicationComplete="initSound();addEventListeners(); fadeTargets=new Array(playProgress, caption);" creationComplete="initCallBacks();" mouseDown="pause();setFocus();" @@ -60,6 +60,7 @@ [Bindable] private var txtAlign:String; private var snd:Sound; + private var id3:ID3Info; private var sndCh:SoundChannel; private var sndTr:SoundTransform; private var playResumePosition:Number = 0; @@ -83,31 +84,30 @@ } import mx.controls.Alert; + private function initSound():void { - snd = new Sound(new URLRequest(source)); + snd = new Sound(); id3=null; sndTr = new SoundTransform(vol, pan); - - snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); - snd.addEventListener(ProgressEvent.PROGRESS, progressHandler); - snd.addEventListener(Event.COMPLETE, completeHandler); - + snd.addEventListener(Event.ID3, onID3Info); + snd.addEventListener(IOErrorEvent.IO_ERROR, onError); + snd.addEventListener(ProgressEvent.PROGRESS, onProgress); + snd.addEventListener(Event.COMPLETE, onComplete); + snd.load(new URLRequest(source), new SoundLoaderContext(1000, true)); if(autoPlay) play(); } - import flash.events.MouseEvent; - private function mouseOvrHnd(e:MouseEvent):void { + private function onMouseOver(e:MouseEvent):void { mouseIsOver=true; fadeEffect.end(); playProgress.alpha=caption.alpha=1.0; } - private function mouseOutHnd(e:MouseEvent):void { + private function onMouseOut(e:MouseEvent):void { mouseIsOver=false; fadeEffect.play(); } - import flash.events.KeyboardEvent; - private function keyDnHnd(e:KeyboardEvent):void { + private function onKeyDown(e:KeyboardEvent):void { switch(e.keyCode) { case 32: //space bar playPause(); @@ -179,7 +179,7 @@ } } - private function keyUpHnd(e:KeyboardEvent):void { + private function onKeyUp(e:KeyboardEvent):void { switch(e.keyCode) { case 37: //<-- case 39: //--> @@ -195,50 +195,43 @@ 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); - - if(snd.id3.songName) - fmtd += ' '+ String.fromCharCode(0x2014) + ' ' + snd.id3.songName; - if(snd.id3.artist) fmtd += ' | ' + snd.id3.artist; - if(snd.id3.album) fmtd += ' | ' + snd.id3.album; - - if(snd.id3.songName || snd.id3.artist || snd.id3.album) - txtAlign="start"; - else - txtAlign="center"; - + txtAlign="center"; + try{ + if(id3.songName) + fmtd += ' '+ String.fromCharCode(0x2014) + ' ' + id3.songName; + if(id3.artist) fmtd += ' | ' + id3.artist; + if(id3.album) fmtd += ' | ' + id3.album; + if(id3) txtAlign="start"; + }catch(e:Object){} return fmtd; } - private function addeventlisteners():void { + private function addEventListeners():void { this.setFocus(); this.addEventListener(Event.ENTER_FRAME, onEnterFrame); - this.addEventListener(KeyboardEvent.KEY_DOWN, keyDnHnd); - this.addEventListener(KeyboardEvent.KEY_UP, keyUpHnd); - this.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHnd); - this.addEventListener(MouseEvent.MOUSE_OVER, mouseOvrHnd); + this.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); + this.addEventListener(KeyboardEvent.KEY_UP, onKeyUp); + this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); + this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); } private function setSource(src:String):void { pause(); - snd = new Sound(new URLRequest(src)); - if(autoPlay) play(); + source=src; + initSound(); } private function play():void { if(playing) return; try{sndCh = snd.play(playResumePosition, 0, sndTr);} - catch(err:Error){Alert.show(err.message,'Error');} - sndCh.addEventListener(Event.SOUND_COMPLETE, sndCompleteHandler); + catch(e:Error){Alert.show(e.message,'Error');} + sndCh.addEventListener(Event.SOUND_COMPLETE, onSoundComplete); playing = true; } @@ -300,22 +293,21 @@ ExternalInterface.addCallback("setSource", setSource); } - private function sndCompleteHandler(event:Event):void { + private function onSoundComplete(e:Event):void { playing = false; playResumePosition = 0; if(loop) play(); } - private function completeHandler(event:Event):void { + private function onComplete(e:Event):void { playProgress.indeterminate=false; } - import flash.events.ProgressEvent; - private function progressHandler(event:ProgressEvent):void { + private function onProgress(e:ProgressEvent):void { playProgress.indeterminate=true; } - private function onEnterFrame(event:Event):void { + private function onEnterFrame(e:Event):void { if(!playProgress.indeterminate) { if(playing) { playProgress.setProgress(sndCh.position,snd.length); @@ -335,9 +327,10 @@ } } - import flash.events.IOErrorEvent; - private function errorHandler(errorEvent:IOErrorEvent):void { - Alert.show(errorEvent.text + '\ncould not be loaded','Error'); + private function onID3Info(e:Event):void {id3 = e.target.id3;} + + private function onError(e:ErrorEvent):void { + Alert.show(e.type, e.text); } ]]> </fx:Script> |