Parse() public method

public Parse ( MediaFile file ) : bool
file MediaFile
return bool
Beispiel #1
0
        private bool ParseMetadata()
        {
            //1. pick up first 3 bytes they must be ID3
            var id3 = new byte[3];
            if (!MediaFile.ReadBuffer(id3, 3))
            {
                Logger.FATAL("Unable to read 3 bytes");
                return false;
            }
            if ((id3[0] != 'I') || (id3[1] != 'D') || (id3[2] != '3'))
            {
                Logger.WARN("ID3 not found");
                return false;
            }

            //2. pick up the major version
            byte majorVersion;
            byte minorVersion;
            if (!MediaFile.ReadUInt8(out majorVersion))
            {
                Logger.FATAL("Unable to read 1 byte");
                return false;
            }
            if (!MediaFile.ReadUInt8(out minorVersion))
            {
                Logger.FATAL("Unable to read 1 byte");
                return false;
            }

            //3. Instantiate the proper parser
            var pParser = new ID3Parser(majorVersion, minorVersion);

            //4. Parse
            _tags["tags"] = pParser.GetMetadata();

            return pParser.Parse(MediaFile);

            //5. Process the metadata
        }