Beispiel #1
0
        private void SaveToFile()
        {
            ID3TagV1 id3v1 = new ID3TagV1();

            id3v1.Read(this.currentMedia.Filename);

            id3v1.Title  = this.tbTitle.Text.Trim();
            id3v1.Artist = this.tbArtist.Text.Trim();
            id3v1.Album  = this.tbAlbum.Text.Trim();

            string genre = this.tbGenre.Text.Trim();

            if (Enum.IsDefined(typeof(Tagger.MusicalGenres), genre))
            {
                id3v1.Genre = (Tagger.MusicalGenres)Enum.Parse(typeof(Tagger.MusicalGenres), genre, true);
            }

            id3v1.Year = this.tbYear.Text;

            string track = this.tbTrack.Text.Trim();
            int    trackOk;

            if (int.TryParse(track, out trackOk))
            {
                id3v1.Track = trackOk;
            }

            id3v1.Write();
        }
Beispiel #2
0
        private Song CreateFromOldId3Standard(String filename)
        {
            ReadingResult result = ReadingResult.Failure;

            try
            {
                result = id3v1.Read(filename);
            }
            catch
            {
                return(null);
            }

            if (result != Tagger.ReadingResult.Success)
            {
                return(null);
            }

            this.sizeId3v1 = id3v1.Size;

            Genre genre;

            this.LookForGenre(out genre);

            String songTitle = string.IsNullOrEmpty(id3v1.Title) ? GuessSongName(filename) : id3v1.Title;
            Song   song      = database.Song.FindByName(songTitle);

            song.Filename = filename;
            song.Genre    = genre;

            this.LookForArtist(song);
            //this.LookForGenre(song);
            this.LookForAlbum(song);

            try
            {
                database.SaveChanges();
            }
            catch (System.Data.UpdateException ue)
            {
                //IMedia imedia = ((Song)ue.StateEntries[0].Entity);
                database.DeleteObject(ue.StateEntries[0].Entity);

                return(null);
            }

            return(song);
        }