Album Art, Track Duration, And An Error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tyler Wiebe
    New Member
    • Mar 2011
    • 66

    Album Art, Track Duration, And An Error?

    Okay, I'm using the following to get information from mp3 files
    Code:
            public Track(string Location)
            {
                if (System.IO.File.Exists(Location))
                {
                    System.IO.FileStream FileStream = System.IO.File.OpenRead(Location);
                    System.IO.BinaryReader ByteStream = new System.IO.BinaryReader(FileStream);
    
                    FileStream.Seek(-128, System.IO.SeekOrigin.End);
                    if (System.Text.Encoding.Default.GetString(ByteStream.ReadBytes(3)) == "TAG")
                    {
                        this.Title = System.Text.Encoding.Default.GetString(ByteStream.ReadBytes(30)).Trim();
                        this.Artist = System.Text.Encoding.Default.GetString(ByteStream.ReadBytes(30)).Trim();
                        this.Album = System.Text.Encoding.Default.GetString(ByteStream.ReadBytes(30)).Trim();
                        this.Year = int.Parse(System.Text.Encoding.Default.GetString(ByteStream.ReadBytes(4)).Trim());
    
                        ByteStream.BaseStream.Position = 126;
                        byte[] TrackNumber = ByteStream.ReadBytes(2);
                        if (TrackNumber[0] == 0 && TrackNumber[1] != 0) this.TrackNumber = TrackNumber[1];
    
                        this.Location = Location;
                    }
    
                    FileStream.Close();
                }
            }
    First off, as you can see, this doesn't get the files album artwork, or the duration of the song, so I'm wondering how I can do that.

    Secondly, the function I found for finding the track number doesn't seem to be working at all, and I'd like to know why.

    And lastly, out of all of my mp3 files, only 1002 out of 1093 contain the "TAG" ID, so I'm wondering, why is that, and does anyone know a way to get the missing ones?
Working...