954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Mp3 TagReader

By sandeepparekh9 on May 27th, 2011 3:32 pm

hi..

You will need Taglib - Sharp Library for this purpose .

For Complete understanding and project Download Go to: [snipped]

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TagLib;
 
namespace TagReadermp3
{
    public partial class frmTagReader : Form
    {
        public frmTagReader()
        {
            InitializeComponent();
        }
 
        private void btnSelect_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Mp3 Files | *.mp3";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                lblFile.Text = ofd.FileName;
            }
 
        }
 
        private void btnRead_Click(object sender, EventArgs e)
        {
            TagLib.File mp3 = TagLib.File.Create(lblFile.Text);
            lblAlbum.Text = mp3.Tag.Album;
            lblAritst.Text = GetAllStringsFromArrary(mp3.Tag.AlbumArtists,",");   // Tag.AlbumAritst is a string array 
            lblBitsPerMinute.Text = mp3.Tag.BeatsPerMinute.ToString();
            lblComposers.Text = GetAllStringsFromArrary(mp3.Tag.Composers,",");
            lblCopyright.Text = mp3.Tag.Copyright;
            lblGenre.Text = GetAllStringsFromArrary(mp3.Tag.Genres,",");
            lblTitle.Text = mp3.Tag.Title;
            lblTrack.Text = mp3.Tag.Track.ToString();
            lblYear.Text = mp3.Tag.Year.ToString();
  
        }
 
        public string GetAllStringsFromArrary(string[] strArray,string strDelimeter)
        {
            string strFinal = string.Empty;
 
            for (int i = 0; i < strArray.Length ; i++)
            {
                strFinal += strArray[i];
 
                if (i != strArray.Length - 1)
                {
                    strFinal += strDelimeter;
                }
            }
            return strFinal;
             
 
        }
    }
}

Thank YOU! I was looking for this for a long time, does it do tag editing too?

katmai539
Junior Poster in Training
77 posts since May 2010
Reputation Points: 81
Solved Threads: 8
 

yes it does.. explore the library a bit you will find a Save method there ..

sandeepparekh9
Posting Whiz
367 posts since Dec 2010
Reputation Points: 123
Solved Threads: 71
 

If you need to understand how MP3 tagging works, take a look at this post:
http://www.codeproject.com/KB/vb/mp3id3v1.aspx

Basically, MP3 tagging is implemented by adding this data to the final of the MP3 file, the last 128 bits of MP3 files represent this data.

dxider
Light Poster
33 posts since Mar 2011
Reputation Points: 11
Solved Threads: 5
 

u can find length like below

string strlength = mp3.Properties.Duration.ToString();
sandeepparekh9
Posting Whiz
367 posts since Dec 2010
Reputation Points: 123
Solved Threads: 71
 

Excellent. I was going to make something alike MP3-TagIt, because they stopped developing it. It was the best Tag-manager i've ever used, too bad it's gone now but i can start building an alternative now ^^ so thanks again! this is of great use.

katmai539
Junior Poster in Training
77 posts since May 2010
Reputation Points: 81
Solved Threads: 8
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: