timheuer / taglib-sharp-portable

.NET Portable Class Library implementation of TagLib# (forked from TagLib# main project)
Other
58 stars 33 forks source link

Fixes for being able to save a Tagged File #16

Open Winterleaf opened 8 years ago

Winterleaf commented 8 years ago

Switched Stream out with MemoryStream,

Also created a constructor which allows a byte[] to be passed in as initialization versus just a stream.

There is a issue when you create a stream using a byte[], the stream created is not writable. So this changes converts the byte[] properly to a stream so it is writable. I also added a property to the FileAbstraction that lets you get a byte[] of the new data so the users don't need to convert the stream themselves.

var abs = new StreamFileAbstraction(filename, songData); using (var file = File.Create(abs)) { file.Tag.Album = Album; file.Tag.Title = SongTitle; file.Tag.AlbumArtists = new[] {Artist}; file.Tag.AmazonId = Song.AmazonTrackId; file.Save(); } StorageFile sf = await folder.CreateFileAsync(filename, CreationCollisionOption.FailIfExists); sf.WriteAllBytes(abs.TaggedMediaData);