예제 #1
0
 private static bool ReadID3v2(IntPtr p, TAG_INFO tags)
 {
     if ((p == IntPtr.Zero) || (tags == null))
     {
         return(false);
     }
     try
     {
         ID3v2Reader reader = new ID3v2Reader(p);
         while (reader.Read())
         {
             string key  = reader.GetKey();
             object obj2 = reader.GetValue();
             if (obj2 is string)
             {
                 tags.EvalTagEntry(string.Format("{0}={1}", key, obj2));
             }
             else if ((key == "APIC") && (obj2 is byte[]))
             {
                 TagPicture tagPicture = reader.GetPicture(obj2 as byte[], tags.PictureCount);
                 if (tagPicture != null)
                 {
                     tags.AddPicture(tagPicture);
                 }
             }
         }
         reader.Close();
     }
     catch
     {
         return(false);
     }
     return(true);
 }
예제 #2
0
        private TagPicture GetPicture(Tag pTag)
        {
            TagPicture picture  = null;
            string     mimeType = "Unknown";

            TagPicture.PICTURE_TYPE unknown = TagPicture.PICTURE_TYPE.Unknown;
            string       description        = "";
            MemoryStream input  = null;
            BinaryReader reader = null;

            if (pTag.Name == "WM/Picture")
            {
                try
                {
                    input    = new MemoryStream((byte[])pTag);
                    reader   = new BinaryReader(input);
                    mimeType = Marshal.PtrToStringUni(new IntPtr(reader.ReadInt32()));
                    byte num = reader.ReadByte();
                    try
                    {
                        unknown = (TagPicture.PICTURE_TYPE)num;
                    }
                    catch
                    {
                        unknown = TagPicture.PICTURE_TYPE.Unknown;
                    }
                    description = Marshal.PtrToStringUni(new IntPtr(reader.ReadInt32()));
                    int    length      = reader.ReadInt32();
                    byte[] destination = new byte[length];
                    Marshal.Copy(new IntPtr(reader.ReadInt32()), destination, 0, length);
                    picture = new TagPicture(pTag.Index, mimeType, unknown, description, destination);
                }
                catch
                {
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                    if (input != null)
                    {
                        input.Close();
                    }
                }
            }
            return(picture);
        }
예제 #3
0
 public string PictureGetType(int i)
 {
     if ((i >= 0) && (i <= (this.PictureCount - 1)))
     {
         try
         {
             TagPicture picture = this.pictures[i] as TagPicture;
             return(picture.PictureType.ToString());
         }
         catch
         {
         }
     }
     return(null);
 }
예제 #4
0
 public Image PictureGetImage(int i)
 {
     if ((i >= 0) && (i <= (this.PictureCount - 1)))
     {
         try
         {
             TagPicture picture = this.pictures[i] as TagPicture;
             return(picture.PictureImage);
         }
         catch
         {
         }
     }
     return(null);
 }
예제 #5
0
 public string PictureGetDescription(int i)
 {
     if ((i >= 0) && (i <= (this.PictureCount - 1)))
     {
         try
         {
             TagPicture picture = this.pictures[i] as TagPicture;
             return(picture.Description);
         }
         catch
         {
         }
     }
     return(null);
 }
예제 #6
0
        internal bool AddPicture(TagPicture tagPicture)
        {
            if (tagPicture == null)
            {
                return(false);
            }
            bool flag = false;

            try
            {
                this.pictures.Add(tagPicture);
                flag = true;
            }
            catch
            {
            }
            return(flag);
        }
예제 #7
0
        public ArrayList GetAllPictures()
        {
            ArrayList list  = null;
            ArrayList list2 = this.WMGetAllAttrib("WM/Picture");

            if ((list2 != null) && (list2.Count > 0))
            {
                list = new ArrayList(list2.Count);
                foreach (Tag tag in list2)
                {
                    TagPicture picture = this.GetPicture(tag);
                    if (picture != null)
                    {
                        list.Add(picture);
                    }
                }
            }
            return(list);
        }
예제 #8
0
        public TagPicture GetPicture(byte[] frameValue, int index)
        {
            if (frameValue == null)
            {
                return(null);
            }
            TagPicture picture = null;

            byte[] destinationArray = null;
            try
            {
                TagPicture.PICTURE_TYPE unknown;
                Encoding frameEncoding = this.GetFrameEncoding(frameValue[0]);
                int      offset        = 1;
                string   mimeType      = this.ReadTextZero(frameValue, ref offset);
                offset++;
                byte num2 = frameValue[offset];
                try
                {
                    unknown = (TagPicture.PICTURE_TYPE)num2;
                }
                catch
                {
                    unknown = TagPicture.PICTURE_TYPE.Unknown;
                }
                offset++;
                string description = this.ReadTextZero(frameValue, ref offset, frameEncoding);
                offset++;
                int length = frameValue.Length - offset;
                destinationArray = new byte[length];
                Array.Copy(frameValue, offset, destinationArray, 0, length);
                picture = new TagPicture(index, mimeType, unknown, description, destinationArray);
            }
            catch
            {
            }
            return(picture);
        }