Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Page 1 of 4
1 2 3 ... LastLast
Results 1 to 10 of 32

Thread: Multi Audio Player

  1. #1
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,454
    Rep Power
    8

    Multi Audio Player

    amazing Flash templates

    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

  2. #2
    Member Flash Addict gwulfwud is on a distinguished road
    Join Date
    Nov 2007
    Posts
    59
    Rep Power
    3

    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;
    }

  3. #3
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,454
    Rep Power
    8

    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.

  4. #4
    Member Flash Addict gwulfwud is on a distinguished road
    Join Date
    Nov 2007
    Posts
    59
    Rep Power
    3

    Re: Multi Audio Player

    nice.. thank you sir!

  5. #5
    Member Flash Addict gwulfwud is on a distinguished road
    Join Date
    Nov 2007
    Posts
    59
    Rep Power
    3

    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?

  6. #6
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,454
    Rep Power
    8

    Re: Multi Audio Player

    AddEventListener is fine

  7. #7
    Member Flash Addict gwulfwud is on a distinguished road
    Join Date
    Nov 2007
    Posts
    59
    Rep Power
    3

    Re: Multi Audio Player

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

    thanks for your help

  8. #8
    Member Flash Addict gwulfwud is on a distinguished road
    Join Date
    Nov 2007
    Posts
    59
    Rep Power
    3

    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

  9. #9
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,454
    Rep Power
    8

    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.

  10. #10
    Member Flash Addict gwulfwud is on a distinguished road
    Join Date
    Nov 2007
    Posts
    59
    Rep Power
    3

    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..

+ Reply to Thread
Page 1 of 4
1 2 3 ... LastLast

Similar Threads

  1. Multi Video Player JC Player
    By Flep in forum Utilità di FlepStudio
    Replies: 3
    Last Post: 1 Week Ago, 16:53
  2. Multi Video Player JC Player
    By Flep in forum FlepStudio utilities
    Replies: 3
    Last Post: 4 Weeks Ago, 10:43
  3. Multi FLV Player
    By Flep in forum FlepStudio utilities
    Replies: 66
    Last Post: 25-11-09, 16:16
  4. [AS2] Multi Video/Audio Player HELP!
    By gnosis in forum Flash English
    Replies: 3
    Last Post: 14-03-08, 09:15
  5. multi player audio
    By azeloth in forum AIUTO utilità free
    Replies: 1
    Last Post: 04-09-07, 11:52

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Optimization by vBSEO