Exemplo n.º 1
0
        /// <summary>
        /// Set the frame text
        /// </summary>
        /// <param name="frameId">Frame type</param>
        /// <param name="message">Value set in frame</param>
        private void SetTextFrame(string frameId, string message)
        {
            var frame = FindFrame(frameId);

            if (frame != null)
            {
                if (!String.IsNullOrEmpty(message))
                {
                    ((FrameText)frame).Text = message;
                }
                else
                {
                    _frameModel.Remove(frame);
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(message))
                {
                    FrameText frameText = (FrameText)FrameFactory.Build(frameId);
                    frameText.Text     = message;
                    frameText.TextCode = _textCode;
                    _frameModel.Add(frameText);
                }
            }
        }
Exemplo n.º 2
0
        private TagModel GetFrameModel()
        {
            var frameModel = new TagModel();
            var frameText  = new FrameText("TIT2");

            frameText.TextCode = TextCode.Ascii;
            frameText.Text     = _song;
            frameModel.Add(frameText);

            frameText          = new FrameText("TPE1");
            frameText.TextCode = TextCode.Ascii;
            frameText.Text     = _artist;
            frameModel.Add(frameText);

            frameText          = new FrameText("TALB");
            frameText.TextCode = TextCode.Ascii;
            frameText.Text     = _album;
            frameModel.Add(frameText);

            frameText          = new FrameText("TYER");
            frameText.TextCode = TextCode.Ascii;
            frameText.Text     = _year;
            frameModel.Add(frameText);

            frameText          = new FrameText("TRCK");
            frameText.TextCode = TextCode.Ascii;
            frameText.Text     = _track.ToString(CultureInfo.InvariantCulture);
            frameModel.Add(frameText);

            var frameFullText = new FrameFullText("COMM");

            frameFullText.TextCode    = TextCode.Ascii;
            frameFullText.Language    = "eng";
            frameFullText.Description = "";
            frameFullText.Text        = _comment;
            frameModel.Add(frameFullText);

            if (_genre >= 0 && _genre < _genres.Length)
            {
                // from suggestion in http://sourceforge.net/tracker2/?func=detail&aid=920249&group_id=89188&atid=589317
                frameText          = new FrameText("TCON");
                frameText.TextCode = TextCode.Ascii;
                frameText.Text     = _genres[_genre];
                frameModel.Add(frameText);
            }

            //TODO: Fix this code!!!!!!!!
            frameModel.Header.TagSize        = 0; //TODO: Invalid size, not filled in until write
            frameModel.Header.Version        = 3; // ID3v2.[3].[0]
            frameModel.Header.Revision       = 0;
            frameModel.Header.Unsync         = false;
            frameModel.Header.Experimental   = false;
            frameModel.Header.Footer         = false;
            frameModel.Header.ExtendedHeader = false;

            return(frameModel);
        }