Solved

How to Read Tags from a WMA File

Posted on 2013-01-04
7
1,242 Views
Last Modified: 2013-01-08
Ok I need specific instruction on how to extract meta data (author,title,duration) from a Windows Media Audio file (.wma).  References I have reviewed involve downloading an SDK ,are several pages long, and extremely complicated.  I just want the metadata from the file and put it into strings.

This is what I tried:

public class MusicID3Tag
    {
        public byte[] TAGID = new byte[3];      //  3
        public byte[] Title = new byte[30];     //  30
        public byte[] Artist = new byte[30];    //  30  
        public byte[] Album = new byte[30];     //  30  
        public byte[] Year = new byte[4];       //  4  
        public byte[] Comment = new byte[30];   //  30  
        public byte[] Genre = new byte[1];      //  1
    }

           strFileName = "C:\\Develop\\Apps\\WQFX\\Music\\MySong.wma";
           //Open the file and read the tags.    
                using (FileStream fs = File.OpenRead( strFileName))
 
            {
                if (fs.Length >= 128)
                {
                     MusicID3Tag tag = new MusicID3Tag();
                    fs.Seek(-128, SeekOrigin.End);
                    fs.Read(tag.TAGID, 0, tag.TAGID.Length);
                    fs.Read(tag.Title, 0, tag.Title.Length);
                    //string theTAGID = Encoding.Default.GetString(tag.TAGID); Error: Encoding not recognized

                    //if (theTAGID.Equals("TAG"))
                    {
                       //string Title = Encoding.Default.GetString(tag.Title);  Error: Encoding not recognized
                       //string Artist = Encoding.Default.GetString(tag.Artist);
                    }

                }

Any help would be appreciated.
0
Comment
Question by:Dovberman
  • 4
  • 2
7 Comments
 
LVL 79

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 100 total points
ID: 38746037
Windows Media Player 9 SDK, others are in the specific windows version SDK
Extracting Metadata from Windows Media Files
0
 

Author Comment

by:Dovberman
ID: 38746207
Thank you, I will try this tomorrow.  Will Windows Media Player work on Windows 7?
0
 

Author Comment

by:Dovberman
ID: 38746741
The proposed solution appears to be a GUI.  I need to programatically read the tags. It apears from other articles that thi is done by a COM object that uses ID3Audio tags. Can you help me here with references?

//string Title = Encoding.Default.GetString(tag.Title);  Error: Encoding not recognized
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 19

Accepted Solution

by:
Manoj Patil earned 400 total points
ID: 38750341
0
 

Author Comment

by:Dovberman
ID: 38752647
TechChallenger1.  The download is a 2005 version of Visual Studio which has conversion issues.  However, I expect it to work. I will contact the author.

Thank you.
0
 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 38752837
Converted to VS2010 solution
http://sdrv.ms/UwCztf
0
 

Author Comment

by:Dovberman
ID: 38754897
ve3ofa. Thank you.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question