/// <summary> /// saves vorbis ogg or flac tag information to file /// </summary> /// <param name="taglibFile"></param> public void SaveVorbisTag(VorbisComment taglibFile) { if (taglibFile != null) { //string fName = file.FileName; //AudioFileReader prev = file; if (flacReader != null) { //float curVol = file.Volume; wavePlayer.Stop(); string prevFile = this.fileName; this.flacReader.Close(); this.flacReader.Dispose(); this.flacReader = null; try { taglibFile.SaveMetadata(); } catch (UnauthorizedAccessException) { } catch (Exception) { } this.flacReader = new FlacReader(prevFile); wavePlayer.Init(this.flacReader); //SetVolume(curVol); } else if (vorbisReader != null) { wavePlayer.Stop(); string prevFile = this.fileName; this.vorbisReader.Close(); this.vorbisReader.Dispose(); this.vorbisReader = null; try { taglibFile.SaveMetadata(); } catch (UnauthorizedAccessException) { } catch (Exception) { } this.vorbisReader = new VorbisWaveReader(prevFile); wavePlayer.Init(this.vorbisReader); //SetVolume(curVol); } } }
private void btnUpdate_Click(object sender, EventArgs e) { string title = txtTitle.Text; string artist = txtArtist.Text; string album = txtAlbum.Text; string genre = cbGenre.GetItemText(cbGenre.SelectedItem); uint year = 0; if (nudYear.Text != "" && nudYear.Value != nudYear.Minimum) { uint.TryParse(nudYear.Text, out year); } uint trackNum = 0; if (nudTrackNum.Text != "" && nudTrackNum.Value != nudTrackNum.Minimum) { uint.TryParse(nudTrackNum.Text, out trackNum); } if (file != null) { file.Tag.Title = title; file.Tag.Performers = new string[] { artist }; file.Tag.Album = album; file.Tag.Genres = new string[] { genre }; file.Tag.Year = year; file.Tag.Track = trackNum; try { if (!Utils.IsFileLocked(new FileInfo(fileName))) { file.Save(); } else { player.SaveMp3Tag(file); } } catch (UnauthorizedAccessException) { } catch (Exception) { } } if (vbTagger != null) { vbTagger.Title = title; vbTagger.Artist = artist; vbTagger.Album = album; vbTagger.Genre = genre; vbTagger.Date = year.ToString(); vbTagger.TrackNumber = trackNum.ToString(); try { if (!Utils.IsFileLocked(new FileInfo(fileName))) { vbTagger.SaveMetadata(); } else { player.SaveVorbisTag(vbTagger); } } catch (UnauthorizedAccessException) { } catch (Exception) { } } this.Hide(); }