forked from: flash on 2010-2-6
forked from flash on 2010-2-6 (diff: 95)
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/rblY
*/
<?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"
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:Array id="movieList">
<mx:String>http://sansali.perso.sfr.fr/videos/kc.flv</mx:String>
<mx:String>http://sansali.perso.sfr.fr/videos/lesud.flv</mx:String>
<mx:String>http://localhost/megan3.flv</mx:String>
</mx:Array>
<mx:VBox x="10" y="80" width="211">
<mx:List id="cntlMovie" dataProvider="{movieList}"
width="300" />
</mx:VBox>
</mx:Application>
