flash on 2011-2-15
♥0 |
Line 59 |
Modified 2011-02-15 16:40:29 |
MIT License
archived:2017-03-20 09:06:26
ActionScript3 source code
/**
* Copyright marcsali ( http://wonderfl.net/user/marcsali )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/3VG2
*/
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="chargerMp3()">
<mx:Script>
<![CDATA[
import mx.controls.Alert
import flash.media.Sound;
import flash.media.SoundChannel;
public var mp3:Sound = new Sound();
public var chanson:SoundChannel = new SoundChannel();
public var position:Number = 0;
[Bindable]
public var progression:String;
public function chargerMp3():void
{
var p_chemin:String = "http://sansali.perso.sfr.fr/videos/pil/Home.mp3"
var requete:URLRequest = new URLRequest(p_chemin);
mp3.load(requete)
mp3.addEventListener( Event.COMPLETE, finChargement );
}
public function lire():void
{
chanson = mp3.play(position);
var positionTimer:Timer = new Timer(50);
positionTimer.addEventListener(TimerEvent.TIMER, progressionLecture);
positionTimer.start();
}
private function progressionLecture(e:Event):void{
var p_duree:Number = chanson.position;
var minutes:String;
var secondes:String;
var temps:Date = new Date(0,0,0,0,0,0,p_duree);
minutes = String(temps.getMinutes());
if (temps.getSeconds() < 10 ){secondes = "0"+String(temps.getSeconds())
}else{secondes=String(temps.getSeconds())};
progression = minutes+":"+secondes
}
public function stopper():void
{
chanson.stop();
position = 0;
}
public function mettreEnPause():void
{
position = chanson.position;
chanson.stop();
}
public function finChargement(e:Event):void
{
Alert.show ("Chargement MP3 Terminé")
}
]]>
</mx:Script>
<mx:Button x="10" y="19" label="Lire" id="btn_lire" click="lire()" width="65"/>
<mx:Button x="83" y="19" label="Pause" width="65" id="btn_pause"
click="mettreEnPause()"/>
<mx:Button x="156" y="19" label="Stop" width="65" id="btn_stop" click="stopper()"/>
<mx:TextInput x="10" y="49" width="211" id="txt_progression" text="{progression}"/>
</mx:Application>