4 Replies Latest reply on Jun 27, 2007 12:15 PM by Handycam

    musicPlayer

    ojk007
      Hey all,

      now i love flex, but there is almost no help anywhere. so hopefully you guys can help me or at least point me in the right direction.
      First off im no newbie to coding, i know php/VB/html/xml/ a little java and AS.
      Ok so, for a project im creating i need to be able to play mp3's. this application is only goin to be run at LAN events.

      How do i play mp3's in flex?

      currently my xml is structured as follows

      quote:

      <?xml version="1.0" encoding="utf-8"?>
      <files>
      <song>
      <name>Is This It</name>
      <artist>The Strokes</artist>
      <album>This is It</album>
      <genre>Unknown</genre>
      <bitrate>224
      </bitrate>
      <length>2:35
      </length>
      <filename>01 Is This It.mp3</filename>
      </song>


      they are all in a folder called music, so the relative filename is music/{songList.selectedItem.filename} <- not real code

      how do i get the song to play?
        • 1. Re: musicPlayer
          chris.huston.t10 Level 3
          Here is how you can play a sound in Flex:

          private function play_mp3():void {
          var mp3_sound = new Sound();
          var mp3_file = new URLRequest("music/" + songList.selectedItem.filename);
          mp3_sound.load(mps_file);
          mp3_sound.play();
          }

          You could call this functin from a play button click event or from a list itemClick event.

          Vygo
          • 2. Re: musicPlayer
            ntsiii Level 3
            There is a copmplete example here:
            http://labs.flexcoders.nl/

            And actually there is a lot of pretty good documentation, it is just hard to find it.

            Tracy
            • 3. Re: musicPlayer
              ojk007 Level 1
              thank you so MUCH!!!!

              and thanks for the link.

              i think we can say this has been answered.
              • 4. Re: musicPlayer
                Handycam Level 1
                First I tried the code listed:

                quote:

                private function play_mp3():void {
                var mp3_sound = new Sound();
                var mp3_file = new URLRequest("music/" + songList.selectedItem.filename);
                mp3_sound.load(mps_file);
                mp3_sound.play();
                }



                And Flex 2 showed errors for the variables (not typed) and the 2 methods underneath it.

                So I went to the web site and downloaded the compnent. Running the demo crashed my browser.

                Ideas??