Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*ID3 tags for Wave files.
- ID3 (Identify a MP3) is metadata container most often used for MP3 audio files. ID3 signature contains information about the title track, album, artist name, etc. about the file to be stored in the file itself. Please see ID3.
- Wave files can also store metadata similar ID3.
- The code below shows how to add, delete, and read metadata from the Wav files.*/
- private void WaveTag()
- {
- string fileName = "in.wav";
- WaveReadWriter wrw = new WaveReadWriter(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
- //removes INFO tags from audio stream
- wrw.WriteInfoTag(null);
- //writes INFO tags into audio stream
- Dictionary<WaveInfo, string> tag = new Dictionary<WaveInfo, string>();
- tag[WaveInfo.Comments] = "Comments...";
- wrw.WriteInfoTag(tag);
- wrw.Close();
- //reads INFO tags from audio stream
- WaveReader wr = new WaveReader(File.OpenRead(fileName));
- Dictionary<WaveInfo, string> dir = wr.ReadInfoTag();
- wr.Close();
- if (dir.Count > 0)
- {
- foreach (string val in dir.Values)
- {
- Console.WriteLine(val);
- }
- }
- }
- //In addition, we show how to do the same for mp3 files with ID3 Tag V1.0
- private void Mp3Tag()
- {
- string fileName = "in.mp3";
- Mp3ReadWriter mrw = new Mp3ReadWriter(File.Open(fileName, FileMode.Open, FileAccess.ReadWrite));
- //removes ID3v1 tags from audio stream
- mrw.WriteID3v1Tag(null);
- //writes ID3v1 tags into audio stream
- ID3v1 tag = new ID3v1();
- tag.Comment = "Comment...";
- mrw.WriteID3v1Tag(tag);
- mrw.Close();
- //reads ID3v1 tags from audio stream
- Mp3Reader mr = new Mp3Reader(File.OpenRead(fileName));
- ID3v1 id3v1 = mr.ReadID3v1Tag();
- mr.Close();
- if (id3v1 != null)
- {
- Console.WriteLine(id3v1.Comment);
- }
- }
- //Audio Library needed for this example is here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement