Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

Multi Audio Player

This is a discussion on Multi Audio Player within the FlepStudio utilities forums, part of the Tutorials category; MULTI AUDIO PLAYER web audio player Description Lettore audio mp3 Legge da file XML i brani delle canzoni Files package ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Tutorials > FlepStudio utilities

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 29-09-07, 09:56
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,488
Rep Power: 6
Flep is on a distinguished road
Multi Audio Player


MULTI AUDIO PLAYER

web audio player









Description

Lettore audio mp3

Legge da file XML i brani delle canzoni


Files package

main.fla

Main.as

LoadingXML.as

Grafico.as

canzoni.xml

leggimi.txt

Important : Open the file LoadingXML.as and change the url to XML file..


XML file:

4 attributes: artista, album, titolo, url


Click here to view XML file






Source files:
Attached Files
File Type: zip MultiAudioPlayer.zip (582.2 KB, 522 views)

__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !

Last edited by Flep; 05-06-08 at 16:15..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 15-11-07, 04:30
Member
 
Join Date: Nov 2007
Posts: 59
Rep Power: 2
gwulfwud is on a distinguished road
Re: Multi Audio Player

hey flep..what is the removeEventListener for?

private function cambiaCanzone(n:Number):void
{
pausa_mc.visible=false;
pausa_mc.stop();
channel.removeEventListener(Event.SOUND_COMPLETE,s oundComplete);
timer.stop();
initTimer();
isPause=false;
channel.stop();
position=0;
sound=new Sound(new URLRequest(links_array[n]));
channel=sound.play();
channel.addEventListener(Event.SOUND_COMPLETE,soun dComplete);
playing=true;
isPause=false;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 15-11-07, 07:03
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,488
Rep Power: 6
Flep is on a distinguished road
Re: Multi Audio Player

If you don't need anymore of a listener, remove it.
You gain memory and better performance.

The function cambiaCanzone ( changeSong ) changes the mp3, so i want remove the listener of the last mp3.
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 15-11-07, 14:43
Member
 
Join Date: Nov 2007
Posts: 59
Rep Power: 2
gwulfwud is on a distinguished road
Re: Multi Audio Player

nice.. thank you sir!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 19-11-07, 16:47
Member
 
Join Date: Nov 2007
Posts: 59
Rep Power: 2
gwulfwud is on a distinguished road
Re: Multi Audio Player

hey flep, got a quick question...so is putting alot of eventlisteners going to be a big problem for the cpu usage? if it is what is another option for an eventlistener for a button?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Flash Multi Gallery
  #6 (permalink)  
Old 19-11-07, 17:11
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,488
Rep Power: 6
Flep is on a distinguished road
Re: Multi Audio Player

AddEventListener is fine
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7 (permalink)  
Old 20-11-07, 02:40
Member
 
Join Date: Nov 2007
Posts: 59
Rep Power: 2
gwulfwud is on a distinguished road
Re: Multi Audio Player

thank you! now i can feel im doing the right thing !! =D

thanks for your help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #8 (permalink)  
Old 24-11-07, 18:54
Member
 
Join Date: Nov 2007
Posts: 59
Rep Power: 2
gwulfwud is on a distinguished road
Re: Multi Audio Player

hey flep,

got another problem. well, i don't really know how to go about this...so the issue is, after the songs finishes how can my player detect that the sound is completed and go to the next song? should i use another addeventlistener? i looked into the source files of your multi audio player and it's displaying the eventlistener SOUND_COMPLETE. but then you remove it first then add it again...i got confused with that..can you please explain?


Thank you.
g
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #9 (permalink)  
Old 25-11-07, 06:33
Administrator
 
Join Date: Jul 2007
Location: Cesena
Posts: 4,488
Rep Power: 6
Flep is on a distinguished road
Re: Multi Audio Player

Hi,
SOUND_COMPLETE is what you need.
I removed it when you change the song.

I think he why is pretty logic , if i change the song, i instanciate a new Sound and a new ChannelSound. So, remove every listener and add new listeners.
__________________

 


I recommend: Essential Actionscript 3.0

- Non rispondo ai messaggi privati con domande tecniche. Apri una discussione sul forum !
- I do not reply technicians pvt messages. Open a thread !
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #10 (permalink)  
Old 27-11-07, 04:00
Member
 
Join Date: Nov 2007
Posts: 59
Rep Power: 2
gwulfwud is on a distinguished road
Re: Multi Audio Player

thanks flep!

got another problem though..

Code:
package com.externalFiles
{
       
    import flash.display.MovieClip;
    import flash.display.SimpleButton;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.events.ContextMenuEvent;
    import flash.net.URLRequest;
    
    public class gwPlayerv2 extends MovieClip
    {        
        //modify for xml based mp3
        private var xml:loadsXML;
        public var object_array:Array;
        public var link_array:Array;
        //public var temp_url:String;
        public var totalSong:int;
        
        //sound baryabowls!!
        private var _channel:SoundChannel;
        private var _sound:Sound;
        private var _playing:Boolean;
        //initialize position of the sound (kung sang segundo na ung tugtog
        private var _sposition:int=0;
        private var _songNumber:int=0;
        
        public function gwPlayerv2()
        {
            initVar();
            initButtons();
            kuhaXML();
        }
        
        //simulan ang variables for multiple songs
        public function initVar():void
        {
            //url=new Array();
            object_array=new Array();
            link_array=new Array();
            _playing=false;
        }
        
        private function kuhaXML():void
        {
            xml=new loadsXML(this);
            trace('kuha XML link_array '+link_array);
            trace('total song '+totalSong);
        }
    
                
//*--FIX BUTTONS--**********************************************************************************************************//                
        //initialize buttons
        public function initButtons():void
        {
            playSound.addEventListener(MouseEvent.MOUSE_OVER,chPlayImage);
            pauseSound.addEventListener(MouseEvent.MOUSE_OVER,chPauseImage);
            stopSound.addEventListener(MouseEvent.MOUSE_OVER,chStopImage);
            forwardSound.addEventListener(MouseEvent.MOUSE_OVER,chForwardImage);
            
            playSound.addEventListener(MouseEvent.MOUSE_UP,playSong);
            pauseSound.addEventListener(MouseEvent.MOUSE_UP,pauseSong);
            stopSound.addEventListener(MouseEvent.MOUSE_UP,stopSong);
            forwardSound.addEventListener(MouseEvent.MOUSE_UP,forwardSong);
        }
        
        //change button's images
        public function chPlayImage(event:Event):void
        {
            trace('Mouse Over PLAY');
            trace('link_array '+link_array[0]);
        }
        
        public function chPauseImage(event:Event):void
        {
            trace('Mouse Over PAUSE');
        }
        
        public function chStopImage(event:Event):void
        {
            trace('Mouse Over STOP');
        }
        
        public function chForwardImage(event:Event):void
        {
            trace('Mouse Over FORWARD');
        }
        
        //play song function. pag napindot ung play button
        public function playSong(event:MouseEvent):void
        {
            if(_playing)
            {
                //do nothing since it's already playing
                trace('Music already playing');
                //_channel.addEventListener(Event.SOUND_COMPLETE,songFinish);
            }
            else
            {
                //_channel.stop();
                //para iplay kung san ka nagpause
                //_channel=_sound.play(_sposition);
                _playing=true;    
                //_songNumber=0;
                initSound(_songNumber);
                trace('Music not playing');
            }
        }
        //pause song function
        public function pauseSong(event:MouseEvent):void
        {
            if(_playing)
            {
                _sposition=_channel.position;
                _channel.stop();                
            }
            else
            {
                _channel=_sound.play(_sposition);
            }
            _playing=!_playing;
        }
        //stop song
        public function stopSong(event:MouseEvent):void
        {
            _channel.stop();
            _sposition=0;
            _playing=false;
        }
        
        //forward song
        public function forwardSong(event:MouseEvent):void
        {
            if (_songNumber
            {
                _channel.removeEventListener(Event.SOUND_COMPLETE,songFinish);
                _songNumber=_songNumber+1;
                _channel.stop();
                _sposition=0;
                trace ('IF forward sound position '+_channel.position);
                trace ('forward songnumber '+_songNumber);    
                trace ('forward total song '+totalSong);    
                initSound(_songNumber);
                _channel.addEventListener(Event.SOUND_COMPLETE,songFinish);
            }
            else
            {
                _channel.removeEventListener(Event.SOUND_COMPLETE,songFinish);
                _songNumber=0;
                _channel.stop();
                _sposition=0;
                trace ('forward sound position '+_sposition);
                trace ('ELSE forward total song '+totalSong);    
                initSound(_songNumber);
                _channel.addEventListener(Event.SOUND_COMPLETE,songFinish);
            }
            
        }

//*--PLAY SONG--***********************************************************************************************************//                
        //initialize song function
        private function initSound(n:Number):void
        {
            _channel.removeEventListener(Event.SOUND_COMPLETE,songFinish);
            _sound=new Sound(new URLRequest(link_array[n]));
            trace ('sound position '+_sposition);
            _channel=_sound.play(_sposition);
            _playing=true;
            _channel.addEventListener(Event.SOUND_COMPLETE,songFinish);
        }
        
        /*private function playSound():void
        {
            _channel=_sound.play();
        }*/
        private function songFinish(e:Event):void
        {
            if (_songNumber
            {
                _channel.removeEventListener(Event.SOUND_COMPLETE,songFinish);
                _songNumber=_songNumber+1;
                _channel.stop();
                _sposition=0;
                trace ('IF forward sound position '+_channel.position);
                trace ('forward songnumber '+_songNumber);    
                trace ('forward total song '+totalSong);    
                initSound(_songNumber);
                _channel.addEventListener(Event.SOUND_COMPLETE,songFinish);
            }
            else
            {
                _channel.removeEventListener(Event.SOUND_COMPLETE,songFinish);
                _songNumber=0;
                _channel.stop();
                _sposition=0;
                trace ('forward sound position '+_sposition);
                trace ('ELSE forward total song '+totalSong);    
                initSound(_songNumber);
                _channel.addEventListener(Event.SOUND_COMPLETE,songFinish);
            }
        }
    }
}
now i get this error
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.externalFiles::gwPlayerv2/::initSound()
    at com.externalFiles::gwPlayerv2/playSong()
now i know my logic is right that everytime you click the play song it will remove the listener first then sets up the variables and instances and then adds the listener again..now what i don't know why is that it keeps throwing the null method..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
Multi Video Player Flep Utilità di FlepStudio 29 12-11-08 11:38
Multi FLV Player Flep FlepStudio utilities 31 04-11-08 06:08
Flash CS3 Creare player audio lu91 Flash CS3 generale 2 08-07-08 10:38
[AS2] Multi Video/Audio Player HELP! gnosis Flash CS3 eng 3 14-03-08 09:15
multi player audio azeloth AIUTO utilità free 1 04-09-07 11:52


All times are GMT. The time now is 18:19.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406