diff --git a/src/TaglibSharp.Tests/FileFormats/M4aFormatTest.cs b/src/TaglibSharp.Tests/FileFormats/M4aFormatTest.cs index 8bb33a89b..62dc9b87e 100644 --- a/src/TaglibSharp.Tests/FileFormats/M4aFormatTest.cs +++ b/src/TaglibSharp.Tests/FileFormats/M4aFormatTest.cs @@ -54,10 +54,10 @@ public void bgo_676934 () [Test] public void bgo_701689 () { - // This file contains a musicbrainz track id "883821fc-9bbc-4e04-be79-b4b12c4c4a4e" + // This file contains a musicbrainz recording id "883821fc-9bbc-4e04-be79-b4b12c4c4a4e" // This case also handles bgo #701690 as a proper value for the tag must be returned var file = TagLib.File.Create (TestPath.Samples + "bgo_701689.m4a"); - Assert.AreEqual ("883821fc-9bbc-4e04-be79-b4b12c4c4a4e", file.Tag.MusicBrainzTrackId, "#1"); + Assert.AreEqual ("883821fc-9bbc-4e04-be79-b4b12c4c4a4e", file.Tag.MusicBrainzRecordingId, "#1"); } [Test] diff --git a/src/TaglibSharp.Tests/TaggingFormats/ApeTest.cs b/src/TaglibSharp.Tests/TaggingFormats/ApeTest.cs index 2082f6b80..dd375bae1 100644 --- a/src/TaglibSharp.Tests/TaggingFormats/ApeTest.cs +++ b/src/TaglibSharp.Tests/TaggingFormats/ApeTest.cs @@ -634,6 +634,56 @@ public void TestMusicBrainzTrackID () }); } + [Test] + public void TestMusicBrainzRecordingID () + { + Tag tag = new Tag (); + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m); + }); + + tag.MusicBrainzRecordingId = val_sing; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m); + }); + + tag.MusicBrainzRecordingId = string.Empty; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m); + }); + } + + [Test] + public void TestMusicBrainzWorkID () + { + Tag tag = new Tag (); + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m); + }); + + tag.MusicBrainzWorkId = val_sing; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m); + }); + + tag.MusicBrainzWorkId = string.Empty; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m); + }); + } + [Test] public void TestMusicBrainzDiscID () { @@ -842,4 +892,4 @@ void TagTestWithSave (ref Tag tag, TagTestFunc testFunc) testFunc (tag, "After Save"); } } -} \ No newline at end of file +} diff --git a/src/TaglibSharp.Tests/TaggingFormats/AsfTest.cs b/src/TaglibSharp.Tests/TaggingFormats/AsfTest.cs index 232e9db95..d0ad98459 100644 --- a/src/TaglibSharp.Tests/TaggingFormats/AsfTest.cs +++ b/src/TaglibSharp.Tests/TaggingFormats/AsfTest.cs @@ -633,6 +633,56 @@ public void TestMusicBrainzTrackID () }); } + [Test] + public void TestMusicBrainzRecordingID () + { + var file = CreateFile (out var abst); + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m); + }); + + file.Tag.MusicBrainzRecordingId = val_sing; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m); + }); + + file.Tag.MusicBrainzRecordingId = string.Empty; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m); + }); + } + + [Test] + public void TestMusicBrainzWorkID () + { + var file = CreateFile (out var abst); + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m); + }); + + file.Tag.MusicBrainzWorkId = val_sing; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m); + }); + + file.Tag.MusicBrainzWorkId = string.Empty; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m); + }); + } + [Test] public void TestMusicBrainzDiscID () { diff --git a/src/TaglibSharp.Tests/TaggingFormats/Id3V2Test.cs b/src/TaglibSharp.Tests/TaggingFormats/Id3V2Test.cs index 8b2ea676c..d968a9225 100644 --- a/src/TaglibSharp.Tests/TaggingFormats/Id3V2Test.cs +++ b/src/TaglibSharp.Tests/TaggingFormats/Id3V2Test.cs @@ -744,6 +744,62 @@ public void TestMusicBrainzTrackID () } } + [Test] + public void TestMusicBrainzRecordingID () + { + var tag = new Tag (); + for (byte version = 2; version <= 4; version++) { + tag.Version = version; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m); + }); + + tag.MusicBrainzRecordingId = val_sing; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m); + }); + + tag.MusicBrainzRecordingId = string.Empty; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m); + }); + } + } + + [Test] + public void TestMusicBrainzWorkID () + { + var tag = new Tag (); + for (byte version = 2; version <= 4; version++) { + tag.Version = version; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m); + }); + + tag.MusicBrainzWorkId = val_sing; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m); + }); + + tag.MusicBrainzWorkId = string.Empty; + + TagTestWithSave (ref tag, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m); + }); + } + } + [Test] public void TestMusicBrainzDiscID () { diff --git a/src/TaglibSharp.Tests/TaggingFormats/Mpeg4Test.cs b/src/TaglibSharp.Tests/TaggingFormats/Mpeg4Test.cs index dbc0ca5d6..d36e160ec 100644 --- a/src/TaglibSharp.Tests/TaggingFormats/Mpeg4Test.cs +++ b/src/TaglibSharp.Tests/TaggingFormats/Mpeg4Test.cs @@ -634,6 +634,56 @@ public void TestMusicBrainzTrackID () }); } + [Test] + public void TestMusicBrainzRecordingID () + { + var file = CreateFile (out var abst); + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m); + }); + + file.Tag.MusicBrainzRecordingId = val_sing; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m); + }); + + file.Tag.MusicBrainzRecordingId = string.Empty; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m); + }); + } + + [Test] + public void TestMusicBrainzWorkID () + { + var file = CreateFile (out var abst); + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m); + }); + + file.Tag.MusicBrainzWorkId = val_sing; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m); + }); + + file.Tag.MusicBrainzWorkId = string.Empty; + + TagTestWithSave (ref file, abst, delegate (Tag t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m); + }); + } + [Test] public void TestMusicBrainzDiscID () { diff --git a/src/TaglibSharp.Tests/TaggingFormats/XiphTest.cs b/src/TaglibSharp.Tests/TaggingFormats/XiphTest.cs index c103d1257..5f8db0803 100644 --- a/src/TaglibSharp.Tests/TaggingFormats/XiphTest.cs +++ b/src/TaglibSharp.Tests/TaggingFormats/XiphTest.cs @@ -659,6 +659,56 @@ public void TestMusicBrainzTrackID () }); } + [Test] + public void TestMusicBrainzRecordingID () + { + var tag = new XiphComment (); + + TagTestWithSave (ref tag, delegate (XiphComment t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Initial (Null): " + m); + }); + + tag.MusicBrainzRecordingId = val_sing; + + TagTestWithSave (ref tag, delegate (XiphComment t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzRecordingId, "Value Set (!Null): " + m); + }); + + tag.MusicBrainzRecordingId = string.Empty; + + TagTestWithSave (ref tag, delegate (XiphComment t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzRecordingId, "Value Cleared (Null): " + m); + }); + } + + [Test] + public void TestMusicBrainzWorkID () + { + var tag = new XiphComment (); + + TagTestWithSave (ref tag, delegate (XiphComment t, string m) { + Assert.IsTrue (t.IsEmpty, "Initial (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Initial (Null): " + m); + }); + + tag.MusicBrainzWorkId = val_sing; + + TagTestWithSave (ref tag, delegate (XiphComment t, string m) { + Assert.IsFalse (t.IsEmpty, "Value Set (!IsEmpty): " + m); + Assert.AreEqual (val_sing, t.MusicBrainzWorkId, "Value Set (!Null): " + m); + }); + + tag.MusicBrainzWorkId = string.Empty; + + TagTestWithSave (ref tag, delegate (XiphComment t, string m) { + Assert.IsTrue (t.IsEmpty, "Value Cleared (IsEmpty): " + m); + Assert.IsNull (t.MusicBrainzWorkId, "Value Cleared (Null): " + m); + }); + } + [Test] public void TestMusicBrainzDiscID () { diff --git a/src/TaglibSharp/Ape/Tag.cs b/src/TaglibSharp/Ape/Tag.cs index c3b631b6b..4ad703c25 100644 --- a/src/TaglibSharp/Ape/Tag.cs +++ b/src/TaglibSharp/Ape/Tag.cs @@ -1420,14 +1420,48 @@ public override string MusicBrainzReleaseArtistId { /// or if no value is present. /// /// - /// This property is implemented using the "MUSICBRAINZ_TRACKID" item. + /// This property is implemented using the "MUSICBRAINZ_RELEASETRACKID" item. /// http://musicbrainz.org/doc/PicardTagMapping /// public override string MusicBrainzTrackId { + get { return GetItemAsString ("MUSICBRAINZ_RELEASETRACKID"); } + set { SetValue ("MUSICBRAINZ_RELEASETRACKID", value); } + } + + /// + /// Gets and sets the MusicBrainz RecordingID + /// + /// + /// A containing the MusicBrainz + /// RecordingID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "MUSICBRAINZ_TRACKID" frame. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzRecordingId { get { return GetItemAsString ("MUSICBRAINZ_TRACKID"); } set { SetValue ("MUSICBRAINZ_TRACKID", value); } } + /// + /// Gets and sets the MusicBrainz WorkID + /// + /// + /// A containing the MusicBrainz + /// WorkID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "MUSICBRAINZ_WORKID" frame. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzWorkId { + get { return GetItemAsString ("MUSICBRAINZ_WORKID"); } + set { SetValue ("MUSICBRAINZ_WORKID", value); } + } + /// /// Gets and sets the MusicBrainz Disc ID of the media /// represented by the current instance. diff --git a/src/TaglibSharp/Asf/Tag.cs b/src/TaglibSharp/Asf/Tag.cs index 84717ba22..72872b32b 100644 --- a/src/TaglibSharp/Asf/Tag.cs +++ b/src/TaglibSharp/Asf/Tag.cs @@ -1176,15 +1176,49 @@ public override string MusicBrainzReleaseArtistId { /// instance or null if no value is present. /// /// - /// This property is implemented using the "MusicBrainz/Track Id" + /// This property is implemented using the "MusicBrainz/Release Track Id" /// field. /// http://musicbrainz.org/doc/PicardTagMapping /// public override string MusicBrainzTrackId { + get { return GetDescriptorString ("MusicBrainz/Release Track Id"); } + set { SetDescriptorString (value, "MusicBrainz/Release Track Id"); } + } + + /// + /// Gets and sets the MusicBrainz RecordingID + /// + /// + /// A containing the MusicBrainz + /// RecordingID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "MusicBrainz/Track Id" field. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzRecordingId { get { return GetDescriptorString ("MusicBrainz/Track Id"); } set { SetDescriptorString (value, "MusicBrainz/Track Id"); } } + /// + /// Gets and sets the MusicBrainz WorkID + /// + /// + /// A containing the MusicBrainz + /// WorkID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "MusicBrainz/Work Id" field. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzWorkId { + get { return GetDescriptorString ("MusicBrainz/Work Id"); } + set { SetDescriptorString (value, "MusicBrainz/Work Id"); } + } + /// /// Gets and sets the MusicBrainz Disc ID of /// the media described by the current instance. diff --git a/src/TaglibSharp/CombinedTag.cs b/src/TaglibSharp/CombinedTag.cs index 009eb8faa..5d5b57fc1 100644 --- a/src/TaglibSharp/CombinedTag.cs +++ b/src/TaglibSharp/CombinedTag.cs @@ -1408,6 +1408,82 @@ public override string MusicBrainzTrackId { tag.MusicBrainzTrackId = value; } } + + /// + /// Gets and sets the MusicBrainz Recording ID. + /// + /// + /// A containing the MusicBrainz + /// RecordingID for the media described by the + /// current instance or null if no value is present. + /// + /// + /// When getting the value, the child tags are looped + /// through in order and the first non- + /// and non-empty value is returned. + /// When setting the value, it is stored in each child + /// tag. + /// + /// + public override string MusicBrainzRecordingId { + get { + foreach (Tag tag in tags) { + if (tag == null) + continue; + + string value = tag.MusicBrainzRecordingId; + + if (value != null) + return value; + } + + return null; + } + + set { + foreach (Tag tag in tags) + if (tag != null) + tag.MusicBrainzRecordingId = value; + } + } + + /// + /// Gets and sets the MusicBrainz Work ID. + /// + /// + /// A containing the MusicBrainz + /// WorkID for the media described by the + /// current instance or null if no value is present. + /// + /// + /// When getting the value, the child tags are looped + /// through in order and the first non- + /// and non-empty value is returned. + /// When setting the value, it is stored in each child + /// tag. + /// + /// + public override string MusicBrainzWorkId { + get { + foreach (Tag tag in tags) { + if (tag == null) + continue; + + string value = tag.MusicBrainzWorkId; + + if (value != null) + return value; + } + + return null; + } + + set { + foreach (Tag tag in tags) + if (tag != null) + tag.MusicBrainzWorkId = value; + } + } /// /// Gets and sets the MusicBrainz Disc ID. diff --git a/src/TaglibSharp/Id3v2/Tag.cs b/src/TaglibSharp/Id3v2/Tag.cs index 1c3676ff7..cd669dc0a 100644 --- a/src/TaglibSharp/Id3v2/Tag.cs +++ b/src/TaglibSharp/Id3v2/Tag.cs @@ -1973,14 +1973,48 @@ public override string MusicBrainzReleaseArtistId { /// instance, or null if no value is present. /// /// - /// This property is implemented using the "UFID:http://musicbrainz.org" frame. + /// This property is implemented using the "TXXX:MusicBrainz Release Track Id" frame. /// http://musicbrainz.org/doc/PicardTagMapping /// public override string MusicBrainzTrackId { + get { return GetUfidText ("MusicBrainz Release Track Id"); } + set { SetUfidText ("MusicBrainz Release Track Id", value); } + } + + /// + /// Gets and sets the MusicBrainz RecordingID + /// + /// + /// A containing the MusicBrainz + /// RecordingID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "UFID:http://musicbrainz.org" frame. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzRecordingId { get { return GetUfidText ("http://musicbrainz.org"); } set { SetUfidText ("http://musicbrainz.org", value); } } + /// + /// Gets and sets the MusicBrainz WorkID + /// + /// + /// A containing the MusicBrainz + /// WorkID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "TXXX:MusicBrainz Work Id" frame. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzWorkId { + get { return GetUfidText ("MusicBrainz Work Id"); } + set { SetUfidText ("MusicBrainz Work Id", value); } + } + /// /// Gets and sets the MusicBrainz DiscID /// diff --git a/src/TaglibSharp/Mpeg4/AppleTag.cs b/src/TaglibSharp/Mpeg4/AppleTag.cs index 020aab182..272662309 100644 --- a/src/TaglibSharp/Mpeg4/AppleTag.cs +++ b/src/TaglibSharp/Mpeg4/AppleTag.cs @@ -1474,10 +1474,44 @@ public override string MusicBrainzReleaseArtistId { /// http://musicbrainz.org/doc/PicardTagMapping /// public override string MusicBrainzTrackId { + get { return GetDashBox ("com.apple.iTunes", "MusicBrainz Release Track Id"); } + set { SetDashBox ("com.apple.iTunes", "MusicBrainz Release Track Id", value); } + } + + /// + /// Gets and sets the MusicBrainz RecordingID + /// + /// + /// A containing the MusicBrainz + /// RecordingID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "dash"/"----" box type. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzRecordingId { get { return GetDashBox ("com.apple.iTunes", "MusicBrainz Track Id"); } set { SetDashBox ("com.apple.iTunes", "MusicBrainz Track Id", value); } } + /// + /// Gets and sets the MusicBrainz WorkID + /// + /// + /// A containing the MusicBrainz + /// WorkID for the media described by the current + /// instance, or null if no value is present. + /// + /// + /// This property is implemented using the "dash"/"----" box type. + /// http://musicbrainz.org/doc/PicardTagMapping + /// + public override string MusicBrainzWorkId { + get { return GetDashBox ("com.apple.iTunes", "MusicBrainz Work Id"); } + set { SetDashBox ("com.apple.iTunes", "MusicBrainz Work Id", value); } + } + /// /// Gets and sets the MusicBrainz DiscID /// diff --git a/src/TaglibSharp/Ogg/GroupedComment.cs b/src/TaglibSharp/Ogg/GroupedComment.cs index 80f2a9004..9fc251002 100644 --- a/src/TaglibSharp/Ogg/GroupedComment.cs +++ b/src/TaglibSharp/Ogg/GroupedComment.cs @@ -1110,6 +1110,66 @@ public override string MusicBrainzTrackId { set { if (tags.Count > 0) tags[0].MusicBrainzTrackId = value; } } + /// + /// Gets and sets the MusicBrainz Recording ID. + /// + /// + /// A containing the MusicBrainz + /// RecordingID for the media described by the + /// current instance or null if no value is present. + /// + /// + /// When getting the value, the child comments are looped + /// through in order and the first non- + /// and non-empty value is returned. + /// When setting the value, it is stored in the first + /// comment. + /// + /// + public override string MusicBrainzRecordingId { + get { + foreach (XiphComment tag in tags) { + string value = tag?.MusicBrainzRecordingId; + + if (!string.IsNullOrEmpty (value)) + return value; + } + + return null; + } + set { if (tags.Count > 0) tags[0].MusicBrainzRecordingId = value; } + } + + /// + /// Gets and sets the MusicBrainz Work ID. + /// + /// + /// A containing the MusicBrainz + /// WorkID for the media described by the + /// current instance or null if no value is present. + /// + /// + /// When getting the value, the child comments are looped + /// through in order and the first non- + /// and non-empty value is returned. + /// When setting the value, it is stored in the first + /// comment. + /// + /// + public override string MusicBrainzWorkId { + get { + foreach (XiphComment tag in tags) { + string value = tag?.MusicBrainzWorkId; + + if (!string.IsNullOrEmpty (value)) + return value; + } + + return null; + } + set { if (tags.Count > 0) tags[0].MusicBrainzWorkId = value; } + } + /// /// Gets and sets the MusicBrainz Disc ID. /// diff --git a/src/TaglibSharp/Ogg/XiphComment.cs b/src/TaglibSharp/Ogg/XiphComment.cs index dd1f98e89..9598baf61 100644 --- a/src/TaglibSharp/Ogg/XiphComment.cs +++ b/src/TaglibSharp/Ogg/XiphComment.cs @@ -1291,13 +1291,47 @@ public override string MusicBrainzReleaseArtistId { /// instance or if no value present. /// /// - /// This property is implemented using the "MUSICBRAINZ_TRACKID" field. + /// This property is implemented using the "MUSICBRAINZ_RELEASETRACKID" field. /// public override string MusicBrainzTrackId { + get { return GetFirstField ("MUSICBRAINZ_RELEASETRACKID"); } + set { SetField ("MUSICBRAINZ_RELEASETRACKID", value); } + } + + /// + /// Gets and sets the MusicBrainz Recording ID for the media + /// represented by the current instance. + /// + /// + /// A object containing the MusicBrainz + /// RecordingID for the media represented by the current + /// instance or if no value present. + /// + /// + /// This property is implemented using the "MUSICBRAINZ_TRACKID" field. + /// + public override string MusicBrainzRecordingId { get { return GetFirstField ("MUSICBRAINZ_TRACKID"); } set { SetField ("MUSICBRAINZ_TRACKID", value); } } + /// + /// Gets and sets the MusicBrainz Work ID for the media + /// represented by the current instance. + /// + /// + /// A object containing the MusicBrainz + /// WorkID for the media represented by the current + /// instance or if no value present. + /// + /// + /// This property is implemented using the "MUSICBRAINZ_WORKID" field. + /// + public override string MusicBrainzWorkId { + get { return GetFirstField ("MUSICBRAINZ_WORKID"); } + set { SetField ("MUSICBRAINZ_WORKID", value); } + } + /// /// Gets and sets the MusicBrainz Disc ID for the media /// represented by the current instance. diff --git a/src/TaglibSharp/Tag.cs b/src/TaglibSharp/Tag.cs index 9e5c00b8b..953a216af 100644 --- a/src/TaglibSharp/Tag.cs +++ b/src/TaglibSharp/Tag.cs @@ -848,6 +848,42 @@ public virtual string MusicBrainzTrackId { set { } } + /// + /// Gets and sets the MusicBrainz Recording ID of the media represented by + /// the current instance. + /// + /// + /// A containing the MusicBrainz RecordingID of the + /// media represented by the current instance or an empty + /// array if no value is present. + /// + /// + /// This field represents the MusicBrainz RecordingID, and is used + /// to uniquely identify a particular recording. + /// + public virtual string MusicBrainzRecordingId { + get { return null; } + set { } + } + + /// + /// Gets and sets the MusicBrainz Work ID of the media represented by + /// the current instance. + /// + /// + /// A containing the MusicBrainz WorkID of the + /// media represented by the current instance or an empty + /// array if no value is present. + /// + /// + /// This field represents the MusicBrainz WorkID, and is used + /// to uniquely identify a particular work. + /// + public virtual string MusicBrainzWorkId { + get { return null; } + set { } + } + /// /// Gets and sets the MusicBrainz Disc ID of the media represented by /// the current instance.