Example #1
0
        public AudioMetadata ReadMetadata(Stream stream)
        {
            TagModel tagModel;

            try
            {
                tagModel = TagManager.Deserialize(stream);
            }
            catch (TagNotFoundException)
            {
                try
                {
                    // If no ID3v2 tag was found, check for ID3v1
                    var v1Tag = new ID3v1();
                    v1Tag.Deserialize(stream);
                    tagModel = v1Tag.FrameModel;
                }
                catch (TagNotFoundException e)
                {
                    throw new AudioUnsupportedException(e.Message);
                }
            }

            return(new TagModelToMetadataAdapter(tagModel));
        }
Example #2
0
 public AudioMetadata ReadMetadata(Stream stream)
 {
     try
     {
         // Check for an ID3v2 tag first
         var tagModel = TagManager.Deserialize(stream);
         return(new TagModelToMetadataAdapter(tagModel));
     }
     catch (TagNotFoundException)
     {
         try
         {
             // If no ID3v2 tag was found, check for ID3v1
             var v1Tag = new Id3V1();
             v1Tag.Deserialize(stream);
             return(new Id3V1ToMetadataAdapter(v1Tag));
         }
         catch (TagNotFoundException e)
         {
             throw new AudioUnsupportedException(e.Message);
         }
     }
 }