2 Replies Latest reply on Nov 6, 2009 9:29 AM by willcba

    mp3 player

    willcba Level 1

      hi i'm new at flash builder, and i made a mp3 player in catalyst but i'm having problem making it work on flash builder.

      It has a play, pause, next, previous button and and a playlist..

      can someone help me please.

      thanks....

        • 1. Re: mp3 player
          nikos101 Level 2

          Please study the flex 4 sound class:

           

          package {
              import flash.display.Sprite;
              import flash.net.URLRequest;
              import flash.media.Sound;
              import flash.text.TextField;
              import flash.text.TextFieldAutoSize;
              import flash.events.ProgressEvent;
              import flash.events.IOErrorEvent;
             
              public class Sound_loadExample extends Sprite {
                  private var snd:Sound = new Sound();
                  private var statusTextField:TextField  = new TextField();

                  public function Sound_loadExample(){

                      statusTextField.autoSize = TextFieldAutoSize.LEFT;
                      var req:URLRequest = new URLRequest("http://av.adobe.com/podcast/csbu_dev_podcast_epi_2.mp3");
                     
                      try {
                      snd.load(req);
                     
                      snd.play();
                      }
                      catch (err:Error) {
                          trace(err.message);
                      }

                      snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
                      snd.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                              
                      this.addChild(statusTextField);
                  }
             
                  private function progressHandler(event:ProgressEvent):void {
                      var loadTime:Number = event.bytesLoaded / event.bytesTotal;
                      var LoadPercent:uint = Math.round(100 * loadTime);
                       
                      statusTextField.text = "Sound file's size in bytes: " + event.bytesTotal + "\n"
                                           + "Bytes being loaded: " + event.bytesLoaded + "\n"
                                           + "Percentage of sound file that is loaded " + LoadPercent + "%.\n";
                  }

                  private function errorHandler(errorEvent:IOErrorEvent):void {
                      statusTextField.text = "The sound could not be loaded: " + errorEvent.text;
                  }
              }
          }


          If you have found my post helpful please mark it so. Many thanks
          • 2. Re: mp3 player
            willcba Level 1

            Hi as i said i'm not a good programmer and i didin't understand that example  very well so if you could make a example of the hole player it would be easier. so please help me thanks...