arkadaşalar, as3 ve xml ile bir mp3 player yaptım...bunda previous, next, play, pause ve stop butonu var....iki tane ise dynamic teşt alanı var ben süre için yapmış olduğum küçük diynamiik text alanındaçalan parçanın artan yada azalan yada sabit hiçbir şekilde süresini gçsteremiyorum
diğer text alanında ise xml den gelin veri ile otomaitk şarkı bilgisi görüntüleniyor ama şarkının ne kadar süre oyanyıp ne kadar süre kaldığını gösteren bir metin alanı yapmak istyorum...nasıl yaparım???teşekkürler....
işte kullandığım kodlar
Code:
var my_songs:XMLList;
var my_total:Number;
var my_sound:Sound;
var my_channel:SoundChannel;
var current_song:Number = 0;
var song_position:Number;
var song_paused:Boolean;
btn_dsn.addEventListener(MouseEvent.CLICK, butonClick);
function butonClick(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.gurseldesign.com"), "_blank");
}
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("playlist.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
my_songs = myXML.SONG;
my_total = my_songs.length();
//playSong(0);
myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
myXMLLoader = null;
}
function playSong(mySong:Number):void {
var myTitle = my_songs[mySong].@TITLE;
var myTIME = my_songs[mySong].@TIME;
var myURL = my_songs[mySong].@URL;
title_txt.text = myTitle;
time_txt.text = myTIME;
if (my_channel) {
my_channel.stop();
my_channel.removeEventListener(Event.SOUND_COMPLETE, onNext);
}
my_sound = new Sound();
my_sound.load(new URLRequest(myURL));
my_channel = my_sound.play();
my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);
}
next_btn.addEventListener(MouseEvent.CLICK, onNext);
function onNext(e:Event):void {
current_song++;
if (current_song>=my_total) {
current_song=0;
}
playSong(current_song);
}
prev_btn.addEventListener(MouseEvent.CLICK, onPrev);
function onPrev(e:MouseEvent):void {
current_song--;
if (current_song<0) {
current_song = my_total-1;
}
playSong(current_song);
}
pause_btn.addEventListener(MouseEvent.CLICK, onPause);
function onPause(e:MouseEvent):void {
if (my_channel) {
song_position = my_channel.position;
my_channel.stop();
song_paused=true;
}
}
play_btn.addEventListener(MouseEvent.CLICK, onPlay);
function onPlay(e:MouseEvent):void {
if (song_paused) {
my_channel = my_sound.play(song_position);
song_paused=false;
} else if (!my_channel) {
playSong(current_song);
}
}
__________________
işte kullandığım kodlar
Code:
var my_songs:XMLList;
var my_total:Number;
var my_sound:Sound;
var my_channel:SoundChannel;
var current_song:Number = 0;
var song_position:Number;
var song_paused:Boolean;
btn_dsn.addEventListener(MouseEvent.CLICK, butonClick);
function butonClick(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.gurseldesign.com"), "_blank");
}
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("playlist.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
my_songs = myXML.SONG;
my_total = my_songs.length();
//playSong(0);
myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
myXMLLoader = null;
}
function playSong(mySong:Number):void {
var myTitle = my_songs[mySong].@TITLE;
var myTIME = my_songs[mySong].@TIME;
var myURL = my_songs[mySong].@URL;
title_txt.text = myTitle;
time_txt.text = myTIME;
if (my_channel) {
my_channel.stop();
my_channel.removeEventListener(Event.SOUND_COMPLETE, onNext);
}
my_sound = new Sound();
my_sound.load(new URLRequest(myURL));
my_channel = my_sound.play();
my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);
}
next_btn.addEventListener(MouseEvent.CLICK, onNext);
function onNext(e:Event):void {
current_song++;
if (current_song>=my_total) {
current_song=0;
}
playSong(current_song);
}
prev_btn.addEventListener(MouseEvent.CLICK, onPrev);
function onPrev(e:MouseEvent):void {
current_song--;
if (current_song<0) {
current_song = my_total-1;
}
playSong(current_song);
}
pause_btn.addEventListener(MouseEvent.CLICK, onPause);
function onPause(e:MouseEvent):void {
if (my_channel) {
song_position = my_channel.position;
my_channel.stop();
song_paused=true;
}
}
play_btn.addEventListener(MouseEvent.CLICK, onPlay);
function onPlay(e:MouseEvent):void {
if (song_paused) {
my_channel = my_sound.play(song_position);
song_paused=false;
} else if (!my_channel) {
playSong(current_song);
}
}
__________________