Solved

How to Read Tags from a WMA File

Posted on 2013-01-04
7
1,213 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 78

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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 78

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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now