Exemplo n.º 1
0
        /// <summary>
        /// Load spefic frame information
        /// </summary>
        /// <param name="FrameID">FrameID to load</param>
        /// <param name="FileAddress">FileAddress to read tag from</param>
        private void LoadFrameFromFile(string FrameID, string FileAddress)
        {
            ID3v2 LinkedInfo = new ID3v2(FileAddress, false);
            LinkedInfo.Filter.Add(FrameID);
            LinkedInfo.FilterType = FilterTypes.LoadFiltersOnly;
            LinkedInfo.Load();

            if (LinkedInfo.HadError)
                foreach (ID3Error IE in LinkedInfo.Errors)
                    _Errors.Add(new ID3Error("In Linked Info(" +
                        FileAddress + "): " + IE.Message, IE.FrameID));

            foreach (TextFrame TF in LinkedInfo._TextFrames)
                _TextFrames.Add(TF);

            foreach (UserTextFrame UT in LinkedInfo._UserTextFrames)
                _UserTextFrames.Add(UT);

            foreach (PrivateFrame PF in LinkedInfo._PrivateFrames)
                _PrivateFrames.Add(PF);

            foreach (TextWithLanguageFrame TWLF in LinkedInfo._TextWithLangFrames)
                _TextWithLangFrames.Add(TWLF);

            foreach (SynchronisedText ST in LinkedInfo._SynchronisedTextFrames)
                _SynchronisedTextFrames.Add(ST);

            foreach (AttachedPictureFrame AP in LinkedInfo._AttachedPictureFrames)
                _AttachedPictureFrames.Add(AP);

            foreach (GeneralFileFrame GF in LinkedInfo._EncapsulatedObjectFrames)
                _EncapsulatedObjectFrames.Add(GF);

            foreach (PopularimeterFrame PF in LinkedInfo._PopularimeterFrames)
                _PopularimeterFrames.Add(PF);

            foreach (AudioEncryptionFrame AE in LinkedInfo._AudioEncryptionFrames)
                _AudioEncryptionFrames.Add(AE);

            // Link to LinkFrame is not available

            foreach (TermOfUseFrame TU in LinkedInfo._TermOfUseFrames)
                _TermOfUseFrames.Add(TU);

            foreach (DataWithSymbolFrame DWS in LinkedInfo._DataWithSymbolFrames)
                _DataWithSymbolFrames.Add(DWS);

            foreach (BinaryFrame BF in LinkedInfo._UnknownFrames)
                _UnknownFrames.Add(BF);

            if (LinkedInfo._MCDIFrame != null)
                _MCDIFrame = LinkedInfo._MCDIFrame;

            if (LinkedInfo._SYTCFrame != null)
                _SYTCFrame = LinkedInfo._SYTCFrame;

            if (LinkedInfo._PCNTFrame != null)
                _PCNTFrame = LinkedInfo._PCNTFrame;

            if (LinkedInfo._RBUFFrame != null)
                _RBUFFrame = LinkedInfo._RBUFFrame;

            if (LinkedInfo._OWNEFrame != null)
                _OWNEFrame = LinkedInfo._OWNEFrame;

            if (LinkedInfo._COMRFrame != null)
                _COMRFrame = LinkedInfo._COMRFrame;

            if (LinkedInfo._RVRBFrame != null)
                _RVRBFrame = LinkedInfo._RVRBFrame;

            if (LinkedInfo._EQUAFrame != null)
                _EQUAFrame = LinkedInfo._EQUAFrame;

            if (LinkedInfo._RVADFrame != null)
                _RVADFrame = LinkedInfo._RVADFrame;

            if (LinkedInfo._ETCOFrame != null)
                _ETCOFrame = LinkedInfo._ETCOFrame;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add Frame information to where it must store
        /// </summary>
        /// <param name="Data">FileStream contain Frame</param>
        /// <param name="FrameID">FrameID of frame</param>
        /// <param name="Length">Maximum available length to read</param>
        /// <param name="Flags">Flags of frame</param>
        private bool AddFrame(FileStreamEx Data, string FrameID, int Length, FrameFlags Flags)
        {
            // NOTE: All FrameIDs must be capital letters
            if (!FramesInfo.IsValidFrameID(FrameID))
            {
                AddError(new ID3Error("nonValid Frame found and dropped", FrameID));
                return false;
            }

            int IsText = FramesInfo.IsTextFrame(FrameID, _ver.Minor);
            if (IsText == 1)
            {
                TextFrame TempTextFrame = new TextFrame(FrameID, Flags, Data, Length);
                if (TempTextFrame.IsReadableFrame)
                {
                    _TextFrames.Add(TempTextFrame);
                    return true;
                }
                return false;
            }

            if (IsText == 2)
            {
                UserTextFrame TempUserTextFrame = new UserTextFrame(FrameID, Flags, Data, Length);
                if (TempUserTextFrame.IsReadableFrame)
                {
                    _UserTextFrames.Add(TempUserTextFrame);
                    return true;
                }
                return false;
            }

            switch (FrameID)
            {
                case "UFID":
                case "PRIV":
                    PrivateFrame TempPrivateFrame = new PrivateFrame(FrameID, Flags, Data, Length);
                    if (TempPrivateFrame.IsReadableFrame)
                    {
                        _PrivateFrames.Add(TempPrivateFrame); return true;
                    }
                    else
                        AddError(new ID3Error(TempPrivateFrame.ErrorMessage, FrameID));
                    break;
                case "USLT":
                case "COMM":
                    TextWithLanguageFrame TempTextWithLangFrame = new TextWithLanguageFrame(FrameID, Flags, Data, Length);
                    if (TempTextWithLangFrame.IsReadableFrame)
                    { _TextWithLangFrames.Add(TempTextWithLangFrame); return true; }
                    else
                        AddError(new ID3Error(TempTextWithLangFrame.ErrorMessage, FrameID));
                    break;
                case "SYLT":
                    SynchronisedText TempSynchronisedText = new SynchronisedText(FrameID, Flags, Data, Length);
                    if (TempSynchronisedText.IsReadableFrame)
                    { _SynchronisedTextFrames.Add(TempSynchronisedText); return true; }
                    else
                        AddError(new ID3Error(TempSynchronisedText.ErrorMessage, FrameID));
                    break;
                case "GEOB":
                    GeneralFileFrame TempGeneralFileFrame = new GeneralFileFrame(FrameID, Flags, Data, Length);
                    if (TempGeneralFileFrame.IsReadableFrame)
                    { _EncapsulatedObjectFrames.Add(TempGeneralFileFrame); return true; }
                    else
                        AddError(new ID3Error(TempGeneralFileFrame.ErrorMessage, FrameID));
                    break;
                case "POPM":
                    PopularimeterFrame TempPopularimeterFrame = new PopularimeterFrame(FrameID, Flags, Data, Length);
                    if (TempPopularimeterFrame.IsReadableFrame)
                    { _PopularimeterFrames.Add(TempPopularimeterFrame); return true; }
                    else
                        AddError(new ID3Error(TempPopularimeterFrame.ErrorMessage, FrameID));
                    break;
                case "AENC":
                    AudioEncryptionFrame TempAudioEncryptionFrame = new AudioEncryptionFrame(FrameID, Flags, Data, Length);
                    if (TempAudioEncryptionFrame.IsReadableFrame)
                    { _AudioEncryptionFrames.Add(TempAudioEncryptionFrame); return true; }
                    else
                        AddError(new ID3Error(TempAudioEncryptionFrame.ErrorMessage, FrameID));
                    break;
                case "USER":
                    TermOfUseFrame TempTermOfUseFrame = new TermOfUseFrame(FrameID, Flags, Data, Length);
                    if (TempTermOfUseFrame.IsReadableFrame)
                    { _TermOfUseFrames.Add(TempTermOfUseFrame); return true; }
                    else
                        AddError(new ID3Error(TempTermOfUseFrame.ErrorMessage, FrameID));
                    break;
                case "ENCR":
                case "GRID":
                    DataWithSymbolFrame TempDataWithSymbolFrame = new DataWithSymbolFrame(FrameID, Flags, Data, Length);
                    if (TempDataWithSymbolFrame.IsReadableFrame)
                    { _DataWithSymbolFrames.Add(TempDataWithSymbolFrame); return true; }
                    else
                        AddError(new ID3Error(TempDataWithSymbolFrame.ErrorMessage, FrameID));
                    break;
                case "LINK":
                    LinkFrame LF = new LinkFrame(FrameID, Flags, Data, Length);
                    if (LF.IsReadableFrame)
                    {
                        _LinkFrames.Add(LF);
                        if (_LoadLinkedFrames)
                        { LoadFrameFromFile(LF.FrameIdentifier, LF.URL); return true; }
                    }
                    else
                        AddError(new ID3Error(LF.ErrorMessage, FrameID));
                    break;
                case "APIC":
                    AttachedPictureFrame TempAttachedPictureFrame = new AttachedPictureFrame(FrameID, Flags, Data, Length);
                    if (TempAttachedPictureFrame.IsReadableFrame)
                    { _AttachedPictureFrames.Add(TempAttachedPictureFrame); return true; }
                    else
                        AddError(new ID3Error(TempAttachedPictureFrame.ErrorMessage, FrameID));
                    break;
                case "MCDI":
                    BinaryFrame MCDI = new BinaryFrame(FrameID, Flags, Data, Length);
                    if (MCDI.IsReadableFrame)
                    { _MCDIFrame = MCDI; return true; }
                    else
                        AddError(new ID3Error(MCDI.ErrorMessage, FrameID));
                    break;
                case "SYTC":
                    SynchronisedTempoFrame SYTC = new SynchronisedTempoFrame(FrameID, Flags, Data, Length);
                    if (SYTC.IsReadableFrame)
                    { _SYTCFrame = SYTC; return true; }
                    else
                        AddError(new ID3Error(SYTC.ErrorMessage, FrameID));
                    break;
                case "PCNT":
                    PlayCounterFrame PCNT = new PlayCounterFrame(FrameID, Flags, Data, Length);
                    if (PCNT.IsReadableFrame)
                    { _PCNTFrame = PCNT; return true; }
                    else
                        AddError(new ID3Error(PCNT.ErrorMessage, FrameID));
                    break;
                case "RBUF":
                    RecomendedBufferSizeFrame RBUF = new RecomendedBufferSizeFrame(FrameID, Flags, Data, Length);
                    if (RBUF.IsReadableFrame)
                    { _RBUFFrame = RBUF; return true; }
                    else
                        AddError(new ID3Error(RBUF.ErrorMessage, FrameID));
                    break;
                case "OWNE":
                    OwnershipFrame OWNE = new OwnershipFrame(FrameID, Flags, Data, Length);
                    if (OWNE.IsReadableFrame)
                    { _OWNEFrame = OWNE; return true; }
                    else
                        AddError(new ID3Error(OWNE.ErrorMessage, FrameID));
                    break;
                case "COMR":
                    CommercialFrame COMR = new CommercialFrame(FrameID, Flags, Data, Length);
                    if (COMR.IsReadableFrame)
                    { _COMRFrame = COMR; return true; }
                    else
                        AddError(new ID3Error(COMR.ErrorMessage, FrameID));
                    break;
                case "RVRB":
                    ReverbFrame RVRB = new ReverbFrame(FrameID, Flags, Data, Length);
                    if (RVRB.IsReadableFrame)
                    { _RVRBFrame = RVRB; return true; }
                    else
                        AddError(new ID3Error(RVRB.ErrorMessage, FrameID));
                    break;
                case "EQUA":
                    Equalisation EQUA = new Equalisation(FrameID, Flags, Data, Length);
                    if (EQUA.IsReadableFrame)
                    { _EQUAFrame = EQUA; return true; }
                    else
                        AddError(new ID3Error(EQUA.ErrorMessage, FrameID));
                    break;
                case "RVAD":
                    RelativeVolumeFrame RVAD = new RelativeVolumeFrame(FrameID, Flags, Data, Length);
                    if (RVAD.IsReadableFrame)
                    { _RVADFrame = RVAD; return true; }
                    else
                        AddError(new ID3Error(RVAD.ErrorMessage, FrameID));
                    break;
                case "ETCO":
                    EventTimingCodeFrame ETCO = new EventTimingCodeFrame(FrameID, Flags, Data, Length);
                    if (ETCO.IsReadableFrame)
                    { _ETCOFrame = ETCO; return true; }
                    else
                        AddError(new ID3Error(ETCO.ErrorMessage, FrameID));
                    break;
                case "POSS":
                    PositionSynchronisedFrame POSS = new PositionSynchronisedFrame(FrameID, Flags, Data, Length);
                    if (POSS.IsReadableFrame)
                    { _POSSFrame = POSS; return true; }
                    else
                        AddError(new ID3Error(POSS.ErrorMessage, FrameID));
                    break;
                default:
                    BinaryFrame Temp = new BinaryFrame(FrameID, Flags, Data, Length);
                    if (Temp.IsReadableFrame)
                    { _UnknownFrames.Add(Temp); return true; }
                    else
                        AddError(new ID3Error(Temp.ErrorMessage, FrameID));
                    break;
                // TODO: Mpeg Location
            }

            return false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clear all ID3 Tag information
        /// </summary>
        public void ClearAll()
        {
            _TextFrames.Clear();
            _UserTextFrames.Clear();
            _PrivateFrames.Clear();
            _TextWithLangFrames.Clear();
            _SynchronisedTextFrames.Clear();
            _SynchronisedTextFrames.Clear();
            _AttachedPictureFrames.Clear();
            _EncapsulatedObjectFrames.Clear();
            _PopularimeterFrames.Clear();
            _AudioEncryptionFrames.Clear();
            _LinkFrames.Clear();
            _TermOfUseFrames.Clear();
            _DataWithSymbolFrames.Clear();
            _UnknownFrames.Clear();

            _MCDIFrame = null;
            _SYTCFrame = null;
            _PCNTFrame = null;
            _RBUFFrame = null;
            _OWNEFrame = null;
            _COMRFrame = null;
            _RVRBFrame = null;
            _EQUAFrame = null;
            _RVADFrame = null;
            _ETCOFrame = null;
        }