Solved

How to Read Tags from a WMA File

Posted on 2013-01-04
7
1,285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 81

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
How our DevOps Teams Maximize Uptime

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

 
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 81

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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 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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

688 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