Open BourgeoisDirk opened 1 year ago
Full code segment:
_private void ApplyID3Tags_Test(string filepath)
{
using (var file = new Id3.Mp3(filepath, Id3.Mp3Permissions.ReadWrite))
{
var tag = file.GetTag(Id3.Id3TagFamily.Version2X);
if (tag == null)
tag = new Id3.Id3Tag();
tag.Track = Track;
tag.AudioSourceUrl = Url;
tag.ArtistUrls.Add(new Id3.Frames.ArtistUrlFrame(Channel?.uChannel.Url));
tag.Artists.Value.Add(Channel?.Title);
tag.Album = (Playlist == null ? Channel?.Title : Playlist?.Title);
tag.Title = Title;
tag.Subtitle = Description;
tag.RecordingDate = UploadDate.DateTime;
tag.Length = Duration;
foreach (var word in Keywords)
tag.Comments.Add(word);
if (Thumbnail != null)
tag.Pictures.Add(new Id3.Frames.PictureFrame()
{
Description = "Thumbnail",
PictureData = Thumbnail.ToByteArray(),
PictureType = Id3.Frames.PictureType.FrontCover
});
if (!file.WriteTag(tag, Id3.WriteConflictAction.Replace))
throw new Exception("Applying ID3 Tags Failed");
}
}_
Try this approach:
file.WriteTag(tag, Id3Version.V23, WriteConflictAction.Replace);
Hey, so far this is one of the most convenient ID3 Tag Editors I've come across. Only thing is, I can't actually Add an ID3 tag to a freshly created MP3.
This seems simple enough, but I get this error on the "file.WriteTag()" function at the end: "Sequence contains no matching element"
System.InvalidOperationException HResult=0x80131509 Message=Sequence contains no matching element Source=System.Linq StackTrace: at System.Linq.ThrowHelper.ThrowNoMatchException() at Id3.Id3Handler.GetHandler(Id3Version version) at Id3.Mp3.WriteTag(Id3Tag tag, WriteConflictAction conflictAction)
Any clue as to why I can't add an ID3 tag ? PS: GetTag() resulted in null, so i added "new Id3Tag()" Also, "file.AvailableTagVersions" count = 0