2 Replies Latest reply on Jan 25, 2010 11:04 AM by edwinmerced

    Simple M3 Player (websites)

    edwinmerced Level 1

      Any website that forum partipants might have to point me to ome function code to make my simple MP3 Player work?


      <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
               height="151" width="257">


      <mx:SoundEffect id="mySounds" source="@Embed('sounds/sounda.mp3')"/>
           <mx:Button x="15" y="32" label="Play" />
           <mx:Button label="Pause" x="74" y="32"/>
           <mx:Button x="143" y="32" label="Stop" />
           <mx:VSlider x="217" y="9" height="92" id="Volume"/>
           <mx:HSlider x="18" y="90" width="179"/>



        • 1. Re: Simple M3 Player (websites)
          Matt Le Fevre Level 4

          Here's a very simple working MP3 player, found it off google a while back just to play around with.


          Added a timer so i could output the track position. A total botch job, it's by no means tidy or efficient, but it works. Only thing its lacking is volume but that should be fairly simple.


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:net="flash.net.*" xmlns:media="flash.media.*" creationComplete="mySound.load(myURLReq); init()">
                     public var Track:Number;
                     public var myPos:Number = 0;
                     import flash.utils.Timer;
                  import flash.events.TimerEvent;
                  import mx.rpc.events.ResultEvent;
                  private const MS_MASK:String = "000";
                  private const TIMER_INTERVAL:int = 10;
                  private var baseTimer:int;
                  private var t:Timer;
                  private function init():void 
                      t = new Timer(TIMER_INTERVAL);
                      t.addEventListener(TimerEvent.TIMER, updateTimer);
                  private function updateTimer(evt:TimerEvent):void {
                      var d:Date = new Date(getTimer() - baseTimer);
                      var ms:String = (MS_MASK + d.milliseconds).substr(-MS_MASK.length);
                     if (ms > "200")
                             Track = mySoundChannel.position;                       
                  private function startTimer():void {
                      baseTimer = getTimer();
                  private function stopTimer():void {
             <net:URLRequest id="myURLReq" url="http://localhost/sound.mp3" />
             <media:SoundChannel id="mySoundChannel"/>
             <media:Sound id="mySound"/>
             <mx:Panel title="MP3 Player">
               <mx:Text id="prog" />
                 <mx:Button id="play" label="PLAY" click="mySoundChannel = mySound.play(myPos, 0, null); prog.text = 'Playing'" />
                 <mx:Button id="pause" label="PAUSE" click="myPos = mySoundChannel.position; mySoundChannel.stop(); prog.text = 'Paused'" />
                 <mx:Button id="stop" label="STOP" click="mySoundChannel.stop(); prog.text = 'Stopped'; myPos = 0;" />
                 <mx:Label text="{Track}"/>
          1 person found this helpful
          • 2. Re: Simple M3 Player (websites)
            edwinmerced Level 1

            THNX Have used it and am currently working on it.