示例#1
0
 private void ReadContentDescription(Stream stream, Tag tag)
 {
     BinaryReader reader = new BinaryReader(stream);
     ushort [] sizes = new ushort[5];
     
     for(int i = 0; i < sizes.Length; i++) {
         sizes[i] = reader.ReadUInt16();
     }
     
     string [] strings = new string[sizes.Length];
     
     for(int i = 0; i < strings.Length; i++) {
         strings[i] = ReadUtf16String(reader, sizes[i]).Trim();
     }
     
     if(sizes[0] > 0 && strings[0] != String.Empty) {
         tag.SetTitle(strings[0]);
     }
     
     if(sizes[1] > 0 && strings[1] != String.Empty) {
         tag.SetArtist(strings[1]);
     }
     
     if(sizes[3] > 0 && strings[3] != String.Empty) {
         tag.SetComment(strings[3]);
     }
 }
示例#2
0
 private void ReadExtendedDescription(Stream stream, Tag tag) 
 {
     BinaryReader reader = new BinaryReader(stream);
     ushort field_count = reader.ReadUInt16();
     
     for(int i = 0; i < field_count; i++) {
         ushort field_length = reader.ReadUInt16();
         string property_name = ReadUtf16String(reader, field_length);
         ushort property_type = reader.ReadUInt16();
         string property_value = String.Empty;
         
         switch(property_type) {
             case 0:
                 property_value = ReadUtf16String(reader, reader.ReadUInt16());
                 break;
             case 1:
                 stream.Seek(reader.ReadUInt16(), SeekOrigin.Current);
                 break;
             case 2:
                 reader.ReadUInt16();
                 property_value = (reader.ReadUInt32() == 1).ToString();
                 break;
             case 3:
                 property_value = reader.ReadUInt32().ToString();
                 break;
             case 4:
                 property_value = reader.ReadUInt64().ToString();
                 break;
             case 5:
                 property_value = reader.ReadUInt16().ToString();
                 break;
         }
         
         switch(property_name) {
             case "WM/AlbumTitle":
                 tag.SetAlbum(property_value);
                 break;
             case "WM/AlbumArtist": 
                 tag.SetArtist(property_value);
                 break;
             case "WM/TrackNumber":
                 tag.SetTrack(property_value);
                 break;
             case "WM/Year": 
                 tag.SetYear(property_value);
                 break;
             case "WM/Genre": 
                 tag.SetGenre(property_value);
                 break;
         }
     }
 }