Ejemplo n.º 1
0
        bool ParseFramesV2(ID3v2Reader reader)
        {
            while (reader.State == ID3v2ReaderState.ReadFrames)
            {
                if (!reader.ReadFrame(out var frame))
                {
                    return(false);
                }

                if (frame == null)
                {
                    continue;
                }

                switch (frame.ID)
                {
                case "COM": /* TODO */ break;

                case "TT2": /* TODO */ break;

                case "TP1": /* TODO */ break;

                case "TRK": /* TODO */ break;

                case "TEN": /* TODO */ break;

                case "TCO": /* TODO */ break;

                default:     // TODO IMPLEMENT ME
                    break;
                }
                frames.Add(frame);
            }
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the specified buffer starting at index to load all data for this frame
        /// This function will throw exceptions on parser errors.
        /// </summary>
        /// <param name="frameReader">FrameReader to read from.</param>
        public override bool Parse(DataFrameReader frameReader)
        {
            var reader = new ID3v2Reader(frameReader);

            // read header
            Header = reader.ReadHeader(out data);
            if (Header == null)
            {
                return(false);
            }

            // read extended header (may be null)
            if (!reader.ReadExtendedHeader(out extendedHeader))
            {
                return(false);
            }

            // read frames
            switch (Header.Version)
            {
            case 2: if (!ParseFramesV2(reader))
                {
                    return(false);
                }
                break;

            case 3:
            case 4: if (!ParseFrames(reader))
                {
                    return(false);
                }
                break;

            default: return(false);
            }

            // read footer
            if (reader.State == ID3v2ReaderState.ReadFooter)
            {
                if (!reader.ReadFooter(out footer))
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        bool ParseFrames(ID3v2Reader reader)
        {
            while (reader.State == ID3v2ReaderState.ReadFrames)
            {
                if (!reader.ReadFrame(out var frame))
                {
                    if (frames.Count > 0)
                    {
                        if (reader.Available > 0)
                        {
                            Trace.WriteLine(string.Format("Invalid frame in id3v2 tag, ignoring remaining data of {0} bytes.", reader.Available));
                            ParserError = true;
                        }
                        return(true);
                    }
                    return(false);
                }
                if (frame == null)
                {
                    continue;
                }

                switch (frame.ID)
                {
                case "APIC": frame = new ID3v2APICFrame(frame); break;

                case "COMM": frame = new ID3v2COMMFrame(frame); break;

                case "ETCO": frame = new ID3v2ETCOFrame(frame); break;

                case "GEOB": /*TODO*/ break;

                case "IPLS": frame = new ID3v2IPLSFrame(frame); break;

                case "MCDI": frame = new ID3v2MCDIFrame(frame); break;

                case "MLLT": frame = new ID3v2MLLTFrame(frame); break;

                case "NCON": /*TODO*/ break;

                case "PCNT": frame = new ID3v2PCNTFrame(frame); break;

                case "PRIV": frame = new ID3v2PRIVFrame(frame); break;

                case "SYLT": frame = new ID3v2SYLTFrame(frame); break;

                case "SYTC": frame = new ID3v2SYTCFrame(frame); break;

                case "TXXX": frame = new ID3v2TXXXFrame(frame); break;

                case "UFID": frame = new ID3v2UFIDFrame(frame); break;

                case "USLT": frame = new ID3v2USLTFrame(frame); break;

                case "WXXX": frame = new ID3v2WXXXFrame(frame); break;

                case "XSLT": frame = new ID3v2XSLTFrame(frame); break;

                default:     // TODO IMPLEMENT ME
                    switch (frame.ID[0])
                    {
                    case 'W': frame = new ID3v2WebFrame(frame); break;

                    case 'T': frame = new ID3v2TextFrame(frame); break;

                    default: Trace.WriteLine(string.Format("Unknown ID3v2 frame type {0}", frame.ID)); break;
                    }
                    break;
                }
                frames.Add(frame);
            }
            return(true);
        }