Example #1
0
        private void parseMhod(MediaItem media)
        {
            byte[] buff = new byte[4];
            long position = strDB.Position;
            debug("Found mhod");
            seek(8); //skip over mhod to total length
            strDB.Read(buff, 0, 4); //read total length
            long totalLength = System.BitConverter.ToUInt32(buff, 0);
            debug("Size of this mhod is " + totalLength);
            strDB.Read(buff, 0, 4); //now at position 20 of this mhod
            long type = System.BitConverter.ToUInt32(buff, 0);
            if ((type == (long)Types.Album) || (type == (long)Types.Artist) || (type == (long)Types.Genre) ||
                (type == (long)Types.Location) || (type == (long)Types.Title)) //artist, album, title, filename
            {
                debug("Read type : " + type);
                seek(12);
                strDB.Read(buff, 0, 4); //read length of string
                long strLen = System.BitConverter.ToUInt32(buff, 0);
                debug("String length is " + strLen);
                seek(8); //now at position 40 of mhod (actual string)
                byte[] str = new byte[strLen];
                strDB.Read(str, 0, str.Length);
                String theString = new UnicodeEncoding().GetString(str);
                 switch (type)
                {
                    case (long)Types.Title:
                        media.Title = theString;
                        break;
                    case (long)Types.Album:
                        media.Album = theString;
                        break;
                    case (long)Types.Artist:
                        media.Artist = theString;
                        break;
                    case (long)Types.Location:
                        media.Filename = iPodDrive + theString.Replace(':', '\\');
                        break;
                     case (long)Types.Genre:
                         media.Genre = theString;
                        break;
                    default:
                        break;
                }

            }
            strDB.Seek(position, SeekOrigin.Begin);
            strDB.Seek(totalLength, SeekOrigin.Current);
        }