Reading Information from an MP3 File

Environment: Visual Basic .NET

The Mp3Class has two properties:

  • ID3v1: The mp3.s ID3v1; this read-only property returns a Mp3Class.ID3v1TAG structure.
  • Mp3FileInfo: This property returns the System.IO.FileInfo of the current MP3 file.

and the following methods:

  • GetMPEGType() as MPEGType: Returns the Mpeg type of the current Mpeg file (MP3) as a Mp3Class.MPEGType enumeration.
  • GetLayer() as LayerType: Returns the Layer type of the current Mpeg file (MP3) as a Mp3Class.LayerType enumeration.
  • GetProtection() as ProtectionType: Returns the Protection type of the current MP3 file as a Mp3Class.ProtectionType enumeration.
  • IsVBR() as Boolean: Returns true if the MP3 is VBR.
  • GetXingHeader(): Returns a XingHeader structure.
  • For more information, see: http://www.multiweb.cz/twoinches/MP3inside.htm#MP3FileStructure.

  • GetBitrate() as Integer: Returns the bitrate of the current MP3 file in bits per second. If the file is VBR, it returns the average bitrate.
  • GetSamplingRateFreq() as Integer: Returns the sampling rate Frequency of the current MP3 file in Hz.
  • GetChannelMode() as ChannelMode: Returns the Channel mode of the current MP3 file as a Mp3Class.ChannelMode enumeration.
  • GetCopyRight() as CopyRight: Returns the Copyright type of the current MP3 file as a Mp3Class.CopyRight enumeration.
  • GetDuration() as Integer: Returns the duration of the current MP3 file in seconds.
  • GetDurationString() as String: Returns a string with the duration of the current MP3 file in the form of: hh:mm:ss.
  • GetGenreString(ByVal GenreID As Integer) As String: Returns the name of the genre that corresponds to the Current genreID.

I wrote a demo app that demonstrates the use of my class.

I collected all the information needed to write this class from:

Happy coding!!!

George Liaskos, T.E.I. of Piraeus, Automation Dep.

Downloads

Download demo project – 25 Kb
Download source code – 5 Kb

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read