コード例 #1
0
        void changefile(object sender, EventArgs e)
        {
            if (isFileOpened == false)
            {
                MessageBox.Show(
                    "Откройте файл для дальнейшей работы!",
                    "Внимание",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                return;
            }
            Boolean chek       = true;
            var     isNumerick = int.TryParse(textBox1.Text, out int n);

            if (isNumerick)
            {
                if ((Convert.ToInt32(textBox1.Text) < 1920) || (Convert.ToInt32(textBox1.Text) > 2018))
                {
                    chek = false;
                }
            }
            else
            {
                chek = false;
            }
            if (textBox3.Text == "" || textBox4.Text == "")
            {
                chek = false;
            }
            if (chek == false)
            {
                MessageBox.Show(
                    "Песня должна иметь название и исполнителя, а также быть написана в реальное время!",
                    "Предупреждение",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);
                return;
            }
            file.TagHandler.Year     = textBox1.Text;
            file.TagHandler.Album    = textBox2.Text;
            file.TagHandler.Artist   = textBox3.Text;
            file.TagHandler.Song     = textBox4.Text;
            file.TagHandler.Disc     = textBox5.Text;
            file.TagHandler.Genre    = textBox6.Text;
            file.TagHandler.Composer = textBox7.Text;
            file.TagHandler.Comment  = textBox8.Text;
            file.Update();
            MessageBox.Show("Подтверждение прошло успешно!");
        }
コード例 #2
0
        private void onClearFileButtonClick(object sender, EventArgs e)
        {
            if (!File.Exists(fileBrowser.InitialDirectory + fileBrowser.FileName))
            {
                openMessageBox(1);
            }
            else
            {
                Mp3Lib.Mp3File file = new Mp3Lib.Mp3File(fileBrowser.InitialDirectory + fileBrowser.FileName);
                file.TagHandler.Artist  = String.Empty;
                file.TagHandler.Album   = String.Empty;
                file.TagHandler.Track   = String.Empty;
                file.TagHandler.Year    = String.Empty;
                file.TagHandler.Title   = String.Empty;
                file.TagHandler.Picture = null;
                file.Update();
                string fullPath = fileBrowser.FileName;
                string fileName = fileBrowser.SafeFileName;
                string path     = fullPath.Replace(fileName, "");


                foreach (string deletingfile in Directory.GetFiles(path, "*.bak").Where(item => item.EndsWith(".bak")))
                {
                    File.Delete(deletingfile);
                }
                openMessageBox(3);
                clearEntries();
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: arawin1979/AudioRnD
        private void UsingCSLib()
        {
            string[] musicFiles = Directory.GetFiles(txtFolderPath.Text, "*.mp3");
            foreach (string musicFile in musicFiles)
            {
                var mp3 = new Mp3Lib.Mp3File(musicFile);
                mp3.TagHandler.Title    = mp3.TagHandler.Title.Replace(txtFind.Text, txtReplace.Text);
                mp3.TagHandler.Album    = mp3.TagHandler.Album.Replace(txtFind.Text, txtReplace.Text);
                mp3.TagHandler.Artist   = mp3.TagHandler.Artist.Replace(txtFind.Text, txtReplace.Text);
                mp3.TagHandler.Composer = mp3.TagHandler.Composer.Replace(txtFind.Text, txtReplace.Text);

                mp3.TagHandler.Comment = mp3.TagHandler.Comment.Replace(txtFind.Text, txtReplace.Text);
                mp3.TagHandler.Genre   = mp3.TagHandler.Genre.Replace(txtFind.Text, txtReplace.Text);
                mp3.TagHandler.Lyrics  = mp3.TagHandler.Lyrics.Replace(txtFind.Text, txtReplace.Text);
                mp3.TagHandler.Song    = mp3.TagHandler.Song.Replace(txtFind.Text, txtReplace.Text);
                foreach (var item in mp3.TagModel)
                {
                }
                mp3.Update();
                //Console.WriteLine(musicFile);
                //Console.WriteLine(mp3.HasTagOfFamily(Id3TagFamily.FileStartTag).ToString());
                //var x = this.GetValidVersion(mp3);
                //var tag = mp3.GetTag(x.Major, x.Minor);
                //Console.WriteLine("Title: {0}", tag.Title.Value);
                //Console.WriteLine("Artist: {0}", tag.Artists.Value);
                //Console.WriteLine("Album: {0}", tag.Album.Value);
                //Mp3Stream xs = new Mp3Stream(new MemoryStream());

                //mp3.WriteTag(tag, x.Major, x.Minor, WriteConflictAction.Replace);

                //foreach (var item in tag.Frames)
                //{
                //    Console.WriteLine(item.ToString());

                //}
                ////Id3Tag tag = mp3.GetTag(Id3TagFamily.FileStartTag);
                ////Console.WriteLine("Title: {0}", tag.Title.Value);
                ////Console.WriteLine("Artist: {0}", tag.Artists.Value);
                ////Console.WriteLine("Album: {0}", tag.Album.Value);
            }

            foreach (var filename in musicFiles)
            {
                //// Find and Replace the file name
                var newname = filename.Replace(txtFind.Text, txtReplace.Text);
                if (filename != newname)
                {
                    File.Move(filename, newname);
                }
            }
        }
コード例 #4
0
ファイル: frmFileProp.cs プロジェクト: Marcpusu/SngPropMod
        private void Save()
        {
            foreach (string sng in lstSongs)
            {
                mp3 = new Mp3Lib.Mp3File(sng);
                mp3.TagHandler.Album  = txtAlbum.Text;
                mp3.TagHandler.Artist = txtArtist.Text;

                if (!bDirectory)
                {
                    mp3.TagHandler.Title = txtTitle.Text;
                    mp3.TagHandler.Song  = mp3.TagHandler.Title;
                }

                mp3.TagHandler.Picture = pbImage.Image;
                mp3.Update();
            }

            bModified = false;
        }
コード例 #5
0
        private void onSaveButtonClick(object sender, EventArgs e)
        {
            if (File.Exists(fileBrowser.InitialDirectory + fileBrowser.FileName))
            {
                Mp3Lib.Mp3File file = new Mp3Lib.Mp3File(fileBrowser.InitialDirectory + fileBrowser.FileName);
                file.TagHandler.Artist = authorTextBox.Text;
                file.TagHandler.Album  = albumTextBox.Text;
                file.TagHandler.Track  = trackTextBox.Text;
                file.TagHandler.Year   = yearTextBox.Text;
                file.TagHandler.Title  = titleTextBox.Text;
                if (isDebug == true)
                {
                    file.TagHandler.Picture = Properties.Resources.dummy;
                }
                else if (File.Exists(pictureBrowser.InitialDirectory + pictureBrowser.FileName))
                {
                    file.TagHandler.Picture = Image.FromFile(pictureBrowser.InitialDirectory + pictureBrowser.FileName);
                }
                file.Update();

                string fullPath = fileBrowser.FileName;
                string fileName = fileBrowser.SafeFileName;
                string path     = fullPath.Replace(fileName, "");


                foreach (string deletingfile in Directory.GetFiles(path, "*.bak").Where(item => item.EndsWith(".bak")))
                {
                    File.Delete(deletingfile);
                }

                openMessageBox(2);
                clearEntries();
            }
            else
            {
                openMessageBox(1);
            }
        }
コード例 #6
0
        public void ExecuteBulkUpdte()
        {
            string[] musicFiles = Directory.GetFiles(this.FolderName, "*.mp3", (this.IncludeSubFolder? SearchOption.AllDirectories:SearchOption.TopDirectoryOnly));

            foreach (string musicFile in musicFiles)
            {
                var mp3 = new Mp3Lib.Mp3File(musicFile);

                if (string.IsNullOrEmpty(this.Composer) == false)
                {
                    mp3.TagHandler.Composer = this.Composer;
                }

                if (string.IsNullOrEmpty(this.AlbumName) == false)
                {
                    mp3.TagHandler.Album = this.AlbumName;
                }

                if (UpdateFolderNameAsAlbumName)
                {
                    // string Aname = Path.GetDirectoryName(musicFile);
                    mp3.TagHandler.Album = Path.GetFileName(Path.GetDirectoryName(musicFile));
                }

                if (this.Year != null || this.Year > 0)
                {
                    mp3.TagHandler.Year = this.Year.ToString();
                }

                if (string.IsNullOrEmpty(this.Genre) == false)
                {
                    mp3.TagHandler.Genre = this.Genre;
                }

                if (string.IsNullOrEmpty(this.AlbumAritist) == false)
                {
                    var x = mp3.TagModel.Where(c => c.FrameId == "TPE2").FirstOrDefault();
                    if (x == null)
                    {
                        Console.WriteLine("Null");
                        var ft = new Id3Lib.Frames.FrameText("TPE2");
                        ft.Text = this.AlbumAritist;
                        mp3.TagModel.Add(ft);
                    }
                    else
                    {
                        Console.WriteLine("Not Null");
                        ((Id3Lib.Frames.FrameText)x).Text = this.AlbumAritist;
                    }
                }


                if (this.UpdateFSASTitle)
                {
                    string title = System.IO.Path.GetFileNameWithoutExtension(musicFile);
                    mp3.TagHandler.Title = Regex.Replace(title, @"[\d-]", string.Empty).Trim();
                }


                //foreach (var item in mp3.TagModel)
                //{
                //    Console.WriteLine(item.GetType().ToString());

                //    Console.WriteLine(item.FrameId);

                //    Console.WriteLine(((Id3Lib.Frames.FrameText)item).Text);
                //}


                /*   mp3.TagHandler.Title = mp3.TagHandler.Title.Replace(txtFind.Text, txtReplace.Text);
                 * mp3.TagHandler.Album = mp3.TagHandler.Album.Replace(txtFind.Text, txtReplace.Text);
                 * mp3.TagHandler.Artist = mp3.TagHandler.Artist.Replace(txtFind.Text, txtReplace.Text);
                 * mp3.TagHandler.Composer = mp3.TagHandler.Composer.Replace(txtFind.Text, txtReplace.Text);
                 *
                 * mp3.TagHandler.Comment = mp3.TagHandler.Comment.Replace(txtFind.Text, txtReplace.Text);
                 * mp3.TagHandler.Genre = mp3.TagHandler.Genre.Replace(txtFind.Text, txtReplace.Text);
                 * mp3.TagHandler.Lyrics = mp3.TagHandler.Lyrics.Replace(txtFind.Text, txtReplace.Text);
                 * mp3.TagHandler.Song = mp3.TagHandler.Song.Replace(txtFind.Text, txtReplace.Text);
                 * foreach (var item in mp3.TagModel)
                 * {
                 *
                 * }*/


                mp3.Update();

                //Console.WriteLine(musicFile);
                //Console.WriteLine(mp3.HasTagOfFamily(Id3TagFamily.FileStartTag).ToString());
                //var x = this.GetValidVersion(mp3);
                //var tag = mp3.GetTag(x.Major, x.Minor);
                //Console.WriteLine("Title: {0}", tag.Title.Value);
                //Console.WriteLine("Artist: {0}", tag.Artists.Value);
                //Console.WriteLine("Album: {0}", tag.Album.Value);
                //Mp3Stream xs = new Mp3Stream(new MemoryStream());

                //mp3.WriteTag(tag, x.Major, x.Minor, WriteConflictAction.Replace);

                //foreach (var item in tag.Frames)
                //{
                //    Console.WriteLine(item.ToString());

                //}
                ////Id3Tag tag = mp3.GetTag(Id3TagFamily.FileStartTag);
                ////Console.WriteLine("Title: {0}", tag.Title.Value);
                ////Console.WriteLine("Artist: {0}", tag.Artists.Value);
                ////Console.WriteLine("Album: {0}", tag.Album.Value);
            }
        }