예제 #1
0
        /// <summary>Replaces all text frame with the given ID with a single new one with the given value.</summary>
        /// <param name="id">The identifier.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="ArgumentException">Invalid id!.</exception>
        public void ReplaceTextFrame(string id, string value)
        {
            if (!id.StartsWith("T") || id == "TXXX")
            {
                throw new ArgumentException("Invalid id!", nameof(id));
            }

            RemoveFrames(id);
            var frame = ID3v2TextFrame.Create(Header, flags, id, value);

            AddFrame(frame);
        }
예제 #2
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);
        }