3 Replies Latest reply on Jan 5, 2011 5:09 PM by Joe ... Ward

    How to extract metadata from music files in different formats

    Elena Tsvetkova

      Hi, I am working over an AIR application that needs to extract meta data from music files in different formats. It was easy for MP3 format, but there is nothing for other formats. I made a research, there is a lot of software for extracting meta data - but no source code or algorithm. There are open source projects, they use their own libraries, but I was not able to find something for Flex (Action Script). Cam somebody give me an example of source code for extracting music meta data in Flex?

        • 1. Re: How to extract metadata from music files in different formats

          The ActionScript 3.0 sound classes cannot directly load or play sound files in other formats, such as WAV or AIFF. However, starting with Flash Player, AAC audio files can be loaded and played using the NetStream class.We can read the metadata as the following---


          _nStream = new NetStream(_nConnection);
          _nStream.client = this;
          public function onMetaData (info:Object):void {
            trace(" onMetaData ---------------------------------------------------------------");
            for (name in info) {
                 trace ("info." + name + " = " + info[name]);
            trace(" onMetaData ---------------------------------------------------------------");



          And for the other formats, we can  load the sound file as a ByteArray (e.g. with Loader, FileStream, URLStream…) and than construct a swf file in memory that has the sound file bytes embedded.


          And we can read the ID3Info with the following way---

          import flash.events.Event; 
          import flash.media.ID3Info; 
          import flash.media.Sound; 
          var s:Sound = new Sound(); 
          s.addEventListener(Event.ID3, onID3InfoReceived); 
          function onID3InfoReceived(event:Event) 
              var id3:ID3Info = event.target.id3; 
              trace("Received ID3 Info:"); 
              for (var propName:String in id3) 
                  trace(propName + " = " + id3[propName]); 

          1 person found this helpful
          • 2. Re: How to extract metadata from music files in different formats
            Elena Tsvetkova Level 1

            Hi Xiaojing,

            Thank you for your answer. It is useful.

            The problem is: My application is not going to play music or video, it just needs to browse over the disk and create a list of available music files including info like song name, album, artist. All this info is kept in meta-data. Some users can have a lot of music of their computers. That's why I don't want to load the whole file and wait for onMetaData event - it can take a long time. I just want to read the meta-data from the file, but not to load the all file as I need for listening the music of playing the movie.

            I already applied extracting meta-data for MP3 files exactly the way you mentioned, it works fine. I only have to wait for Event.ID3 – I implemented Timer to wait until all my files are processed. Probably, if user has a lot of music on his computer, it will take a lot of time.

            I can try to read AAC the way you advice.

            I am really looking for implementation of your advice for reading the music file as a ByteArray and extracting meta-data. In this case we don't need to load all the file, but just to read part of it.

            Do you have some code implementation?


            Thank you again for your response,


            • 3. Re: How to extract metadata from music files in different formats
              Joe ... Ward Level 4

              You can use the FileStream class to read any file.