Beispiel #1
0
        private void Read(ReadStyle properties_style)
        {
            // Look for FLAC metadata, including vorbis comments

            Scan();

            if (!scanned)
            {
                SetValid(false);
                return;
            }


            if (has_xiph_comment)
            {
                comment = new OggXiphComment(XiphCommentData);
            }
            else
            {
                comment = new OggXiphComment();
            }


            if (properties_style != ReadStyle.None)
            {
                properties = new TagLib.FlacProperties(StreamInfoData, StreamLength, properties_style);
            }
        }
Beispiel #2
0
        private Tag FindFlacTag(TagTypes type, bool create)
        {
            switch (type)
            {
            case TagTypes.Id3v1:
            {
                if (create && id3v1_tag == null)
                {
                    id3v1_tag = new Id3v1Tag();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, id3v1_tag, true);
                    }

                    tag.SetTags(comment, id3v2_tag, id3v1_tag);
                }
                return(id3v1_tag);
            }

            case TagTypes.Id3v2:
            {
                if (create && id3v2_tag == null)
                {
                    id3v2_tag = new Id3v2Tag();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, id3v2_tag, true);
                    }

                    tag.SetTags(comment, id3v2_tag, id3v1_tag);
                }
                return(id3v2_tag);
            }

            case TagTypes.Xiph:
            {
                if (create && comment == null)
                {
                    comment = new OggXiphComment();

                    if (tag != null)
                    {
                        TagLib.Tag.Duplicate(tag, comment, true);
                    }

                    tag.SetTags(comment, id3v2_tag, id3v1_tag);
                }
                return(comment);
            }

            default:
                return(null);
            }
        }
Beispiel #3
0
        private void Read(ReadStyle propertiesStyle)
        {
            long flacDataBegin;
            long flacDataEnd;

            // Look for an ID3v2 tag
            long id3v2Location = FindId3v2();

            if (id3v2Location >= 0)
            {
                id3v2_tag     = new Id3v2Tag(this, id3v2Location);
                flacDataBegin = id3v2Location + id3v2_tag.Header.CompleteTagSize;
            }
            else
            {
                flacDataBegin = 0;
            }

            // Look for an ID3v1 tag
            long id3v1_location = FindId3v1();

            if (id3v1_location >= 0)
            {
                id3v1_tag   = new Id3v1Tag(this, id3v1_location);
                flacDataEnd = id3v1_location;
            }
            else
            {
                flacDataEnd = Length;
            }

            // Look for FLAC metadata, including vorbis comments

            xiph_comment_data = Scan(flacDataBegin, flacDataEnd);

            if (!IsValid)
            {
                return;
            }

            if (XiphCommentData.Count > 0)
            {
                comment = new OggXiphComment(XiphCommentData);
            }

            tag.SetTags(comment, id3v2_tag, id3v1_tag);

            FindFlacTag(TagTypes.Xiph, true);

            if (propertiesStyle != ReadStyle.None)
            {
                properties = new FlacProperties(stream_info_data, stream_length, propertiesStyle);
            }
        }
        public override TagLib.Tag FindTag(TagTypes type, bool create)
        {
            if (type == TagTypes.Xiph)
            {
                if (comment == null && create)
                {
                    comment = new OggXiphComment();
                }

                return(comment);
            }
            else
            {
                return(null);
            }
        }
        //////////////////////////////////////////////////////////////////////////
        // private methods
        //////////////////////////////////////////////////////////////////////////
        private void Read(ReadStyle propertiesStyle)
        {
            ByteVector comment_header_data = GetPacket(1);

            if (comment_header_data.Mid(0, 7) != vorbis_comment_header_id)
            {
                TagLibDebugger.Debug("Vorbis.File.Read() - Could not find the Vorbis comment header.");
                SetValid(false);
                return;
            }

            comment = new OggXiphComment(comment_header_data.Mid(7));

            if (propertiesStyle != ReadStyle.None)
            {
                properties = new OggVorbisProperties(this, propertiesStyle);
            }
        }