Exemplo n.º 1
0
        public FrmMp3TagEditor()
        {
            InitializeComponent();

            cbGenre3v1.DataSource = BCHMP3Utilities.GetGenre();
            cbGenre3v2.DataSource = BCHMP3Utilities.GetGenre();
        }
        private void SaveMp3IdInfo(MP3FileDataType mp3, ref OperationResult op)
        {
            try
            {
                ID3Info id3 = new ID3Info(mp3.FileNamePath, true);

                string track = mp3.Track != null?mp3.Track.ToString() : "1";

                string        title     = !string.IsNullOrEmpty(mp3.SongTitleAndNumeration) ? GetMaxLen(mp3.SongTitleAndNumeration, 30) : string.Empty;
                string        artists   = !string.IsNullOrEmpty(mp3.ArtistsStrList) ? GetMaxLen(mp3.ArtistsStrList, 30) : string.Empty;
                string        album     = !string.IsNullOrEmpty(mp3.Album) ? GetMaxLen(mp3.Album, 30) : string.Empty;
                string        comments  = !string.IsNullOrEmpty(mp3.Comments) ? GetMaxLen(mp3.Comments, 28) : string.Empty;
                List <string> GenreList = BCHMP3Utilities.GetGenre();
                int           genreIndx = GenreList.Contains(mp3.Genre, StringComparer.CurrentCultureIgnoreCase)
                                    ?
                                          GenreList.FindIndex(
                    s =>
                    s.Trim().Equals(mp3.Genre.Trim(), StringComparison.CurrentCultureIgnoreCase))
                                    :
                                          GenreList.FindIndex(
                    s =>
                    s.Trim().Equals("Other", StringComparison.CurrentCultureIgnoreCase));

                id3.ID3v1Info.TrackNumber = byte.Parse(track);
                id3.ID3v1Info.Title       = title;
                id3.ID3v1Info.Artist      = artists;
                id3.ID3v1Info.Album       = album;
                id3.ID3v1Info.Comment     = comments;
                id3.ID3v1Info.Genre       = Convert.ToByte(genreIndx);


                id3.ID3v2Info.SetTextFrame("TRCK", track);
                id3.ID3v2Info.SetTextFrame("TIT2", title);
                id3.ID3v2Info.SetTextFrame("TPE1", artists);
                id3.ID3v2Info.SetTextFrame("TALB", album);
                id3.ID3v2Info.SetTextFrame("WCOM", comments);
                id3.ID3v2Info.SetTextFrame("TCON", GenreList[genreIndx]);

                id3.ID3v2Info.HaveTag = true;

                id3.Save();
            }
            catch (Exception ex)
            {
                op.AddException(ex);
            }
        }
Exemplo n.º 3
0
        private void btnPopWithNameInfo_Click(object sender, EventArgs e)
        {
            OperationResult op = new OperationResult();

            if (!Path.GetExtension(ddtbMp3File.ItemText).ToLower().EndsWith(".mp3"))
            {
                MessageBox.Show("Please enter a valid MP3 file", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            MP3FileDataType me = ckbUseDirForInfo.Checked ? BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmtWithDirInfo(ddtbMp3File.ItemText,
                                                                                                                       dddtbGetRootDir.ItemText, ref op) : BCHMP3Utilities.ConvertFileNameToMP3InfoBCHFrmt(ddtbMp3File.ItemText, ref op);

            if (!op.Success)
            {
                MessageBox.Show(op.GetAllMessages("\n"), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            tbTrack3v1.Text = me.Track != null?me.Track.ToString() : string.Empty;

            tbTitle3v1.Text   = me.SongTitleAndNumeration ?? string.Empty;
            tbArtist3v1.Text  = me.ArtistsStrList ?? string.Empty;
            tbAlbum3v1.Text   = me.Album ?? string.Empty;
            tbComment3v1.Text = me.Comments ?? string.Empty;
            string genre = me.Genre ?? string.Empty;

            genre = string.IsNullOrEmpty(genre) || !BCHMP3Utilities.GetGenre().Contains(genre.Trim(),
                                                                                        StringComparer.CurrentCultureIgnoreCase) ? "150" : genre;
            cbGenre3v1.Genre = genre;

            tbTrack3v2.Text = me.Track != null?me.Track.ToString() : string.Empty;

            tbTitle3v2.Text   = me.SongTitleAndNumeration ?? string.Empty;
            tbArtist3v2.Text  = me.ArtistsStrList ?? string.Empty;
            tbAlbum3v2.Text   = me.Album ?? string.Empty;
            tbComment3v2.Text = me.Comments ?? string.Empty;
            cbGenre3v2.Genre  = me.Genre ?? string.Empty;
        }