Exemple #1
0
        void GetFrame_v34(BinaryReader br)
        {
            int findAll = 0;

            byte[] id = new byte[4];
            ByteReader(id, br);
            string temp = GetContent(id);

            while (findAll != 6 && ((br.BaseStream.Length - br.BaseStream.Position) >= 4))
            {
                switch (temp)
                {
                case "TRCK": TRCK = new MainTag(br, id); findAll++; TRCK.WriteInfo(); break;

                case "TIT2": TIT2 = new MainTag(br, id); findAll++; TIT2.WriteInfo(); break;

                case "TPE1": TPE1 = new MainTag(br, id); findAll++; TPE1.WriteInfo(); break;

                case "TALB": TALB = new MainTag(br, id); findAll++; TALB.WriteInfo(); break;

                case "TYER": TYER = new MainTag(br, id); findAll++; TYER.WriteInfo(); break;

                case "TCON": TCON = new TCON(br, id); findAll++; TCON.WriteInfo(); break;
                }

                id[0] = id[1];
                id[1] = id[2];
                id[2] = id[3];
                id[3] = br.ReadByte();
                temp  = GetContent(id);
            }
        }
Exemple #2
0
        void GetFrameV3(BinaryReader br)
        {
            int findAll = 0;

            byte[] id = new byte[4];
            ByteReader(id, br);
            string temp = GetContent(id);

            while ((findAll != 5 && ((size - br.BaseStream.Position) >= 10)))
            {
                switch (temp)
                {
                case "TIT2": TIT2 = new StringTag(br, id); findAll++; break;

                case "TPE1": TPE1 = new StringTag(br, id); findAll++; break;

                case "TALB": TALB = new StringTag(br, id); findAll++; break;

                case "TYER": TYER = new StringTag(br, id); findAll++; break;

                case "TCON": TCON = new TCON(br, id); findAll++; break;
                }

                id[0] = id[1];
                id[1] = id[2];
                id[2] = id[3];
                id[3] = br.ReadByte();
                temp  = GetContent(id);
            }
        }
Exemple #3
0
        public ID3v23(string way, string title, string artist, string album, string year, string genre)
        {
            // Создание или Пересоздание тега
            this.way = way;
            List <byte> ans  = new List <byte>();
            List <byte> tags = new List <byte>();



            file = File.ReadAllBytes(way).ToList();
            if (ID3_Info(way))
            {
                size = IntMaker(new byte[4] {
                    file[6], file[7], file[8], file[9]
                });
                file.RemoveRange(0, size + 10);
            }

            // sas
            // Я чет забыл. Нужно еще же и ID3_Header сформировать
            // sas



            ans.AddRange(new List <byte>()
            {
                0x49, 0x44, 0x33, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x76
            });

            int sizeOfReload = 0;



            if (!string.IsNullOrEmpty(album))
            {
                TALB = new StringTag();
                tags.AddRange(TALB.GetByteTag(album, "TALB"));
                sizeOfReload++;
                //sizeOfReload += IntMaker(TALB.byteSize) + 10;
            }
            if (!string.IsNullOrEmpty(genre))
            {
                TCON = new TCON();
                tags.AddRange(TCON.GetByteTag(genre, "TCON"));
                sizeOfReload++;
                //sizeOfReload += IntMaker(TCON.byteSize) + 10;
            }
            if (!string.IsNullOrEmpty(title))
            {
                TIT2 = new StringTag();
                tags.AddRange(TIT2.GetByteTag(title, "TIT2"));
                sizeOfReload++;
                //sizeOfReload += IntMaker(TIT2.byteSize) + 10;
            }
            if (!string.IsNullOrEmpty(artist))
            {
                TPE1 = new StringTag();
                tags.AddRange(TPE1.GetByteTag(artist, "TPE1"));
                sizeOfReload++;
                //sizeOfReload += IntMaker(TPE1.byteSize) + 10;
            }
            if (!string.IsNullOrEmpty(year))
            {
                TYER = new StringTag();
                tags.AddRange(TYER.GetByteTag(year, "TYER"));
                sizeOfReload++;
                //sizeOfReload += IntMaker(TYER.byteSize) + 10;
            }


            if (sizeOfReload == 0)
            {
                return;
            }
            else
            {
                //byte[] tempSize = BitConverter.GetBytes(GetEbanyTvoyRotSize(sizeOfReload));
                //byte[] tempSize = BitConverter.GetBytes(GetEbanyTvoyRotSize(4086));


                /*for (int i = (tempSize.Length - 1); i > -1; i--)
                 * {
                 *  ans.Add(tempSize[i]);
                 * }
                 */

                ans.AddRange(tags);

                int remain = 4086 - tags.Count;
                for (int i = 0; i < remain; i++)
                {
                    ans.Add(0x00);
                }

                ans.AddRange(file);


                Data.NewPath = new FileInfo(way).DirectoryName + "\\" + artist + " - " + title + ".mp3";

                if (new FileInfo(Data.NewPath).Exists)
                {
                    if (MessageBox.Show("Файл с таким именем уже существует. Желаете его перезаписать?", "Caption", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                using (FileStream fs = new FileStream(Data.NewPath, FileMode.Create, FileAccess.Write))
                    using (BinaryWriter bw = new BinaryWriter(fs))
                    {
                        bw.Write(ans.ToArray());
                    }
                Data.Costil = true;
                // Data.File.Add(new FileInfo(Data.NewPath));
                if (!(way == Data.NewPath))
                {
                    new FileInfo(way).Delete();
                    Data.Costil = true;
                }
            }

            //

            /*
             *
             * ans.AddRange(file);
             *
             * using (FileStream fs = new FileStream(new FileInfo(way).DirectoryName + "\\" + artist + " - " + title + ".mp3", FileMode.Create, FileAccess.Write))
             * using (BinaryWriter bw = new BinaryWriter(fs))
             * {
             *  bw.Write(ans.ToArray());
             * }
             *
             */
        }