Beispiel #1
0
		public Task<Tag> ReadTags(CancellationToken ct, Stream stream)
		{
			Guard.ForNull(stream, nameof(stream));
			return Task.Run(() =>
			{
				using (var fileAbstraction = new AlwaysOpenStreamFileAbstraction(_witnessFilename, stream))
				using (var file = TagLib.File.Create(fileAbstraction))
				{
					return file.GetTag(_tagTypes, false);
				}
			});
		}
Beispiel #2
0
		public Task WriteTags(CancellationToken ct, Stream stream, Tag tags)
		{
			Guard.ForNull(stream, nameof(stream));
			Guard.ForNull(tags, nameof(tags));
			return Task.Run(() =>
			{
				using (var fileAbstraction = new AlwaysOpenStreamFileAbstraction(_witnessFilename, stream))
				using (var file = TagLib.File.Create(fileAbstraction))
                {
					var fileTags = file.GetTag(_tagTypes, true);
					fileTags.Clear();
					tags.CopyTo(fileTags, true);
					fileTags.Pictures = tags.Pictures;
					file.Save();
				}
			});
		}