Closed ghost closed 8 years ago
is it happening with every MP3 file. What are the sizes of the files and can u put some of the code u r using to write the tags?
Thank you so much for answering on my question!
I use this lib to write tags to music files in winRT app. I first must notice that tagging totally works, it is just that it lasts for 30 seconds and literally!
Btw, it is happening to every file! It is just that the files are in .m4a format, not mp3! Sizes of those files are max 5MB...
Please, wait few seconds for code...
I cannot post the code right now, but I will do it as soon as I can!
My app deals with M4As too along with MP3s and i dont think i have noticed this issue. I will run some tests now and get back to you.
Thank you! Maybe the potential bug is in my code? I will soon post it...
So, writing tags for you happens instantly?
Hi, i just tested it and it fine on my side. And it doesnt happen instantly, it takes about 1~2 seconds for MP3 files which i think is normal.
Strange... I would like that delay is 1-2 seconds for me too... But for me and .m4as in my UWP app the writing process last for 20-30 seconds! In few minutes will post code... Hope you can take a closer look at it?
This is my code... Am I doing something wrong here???
try
{
var writeStream = await file.OpenAsync(FileAccessMode.ReadWrite);
var tagFile = TagLib.File.Create(new StreamFileAbstraction(file.Name, writeStream.AsStreamForRead(), writeStream.AsStreamForWrite()));
var tag = tagFile.Tag;
tag.AlbumArtists = new string[] { artistName };
tag.Title = fileName;
tag.Album = albumName;
tagFile.Save();
writeStream.Dispose();
tagFile.Dispose();
}
catch
{
}
ok, if u can place breakpoints on those lines and see which one takes longer to execute.
Will try that now... But, the code is OK?
I would re-write your code like this just to make use of the "using" keyword, so it can dispose everything automatically
try
{
using (var writeStream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
using (var tagFile = TagLib.File.Create(new StreamFileAbstraction(file.Name, writeStream.AsStreamForRead(), writeStream.AsStreamForWrite())))
{
var tag = tagFile.Tag;
tag.AlbumArtists = new string[] { artistName };
tag.Title = fileName;
tag.Album = albumName;
tagFile.Save();
}
}
}
catch (Exception)
{
throw;
}
Here is part of my code
var songStorageFile = await StorageFile.GetFileFromPathAsync(await song.GetLocalSongStorageFilePathAsync());
using (var songFileStream = await songStorageFile.OpenStreamForWriteAsync())
{
using (var tagsFile = File.Create(new StreamFileAbstraction(songStorageFile.Name, songFileStream, songFileStream), songStorageFile.ContentType, ReadStyle.None))
{
tagsFile.RemoveTags(TagTypes.Id3v1 | TagTypes.Id3v2);
var tagsV2 = tagsFile.GetTag(TagTypes.Id3v2, true); // get the ID3v2 tags and if not available let the lib create the frames
tagsV2.Title = song.Name; //set song name as the title
tagsV2.Album = song.Album.Name; //set the album name
tagsV2.AlbumArtists = new string[] { song.Album.Artist.Name }; // use the album artist name as the album artist
tagsFile.Save(); //and then save the tags
}
}
Note that because i am just writing tags and not reading them, i am opening a write stream only.
Thanks for your code! I have used the breakpoints in my code... The line tagFile.Save(); is the problem... 15-20 seconds...
ok give my code a try and see if it will change anything
Will do...
I have tried your first code, but no improvement... I got 18 seconds on tagFile.Save(); ... Any other idea? lolol
@IgorGiga
@punker76
@IgorGiga could u run through your breakpoints again and show me the values of the variables in your tagFile object? i think i have an idea of whats going on.
Sure... But don't know if I understood you... lolol
what i meant was when u r debugging the app, show me the contents of the tagFile object. You know VS can show you the runtime values of any object in scope of the breakpoint.
Will do that soon...
try
{
StatusTextBlock.Text = Resources.GetString("tagsString");
var writeStream = await file.OpenAsync(FileAccessMode.ReadWrite);
var tagFile = TagLib.File.Create(new StreamFileAbstraction(file.Name, writeStream.AsStreamForRead(), writeStream.AsStreamForWrite()));
var tag = tagFile.Tag;
tag.AlbumArtists = new string[] { artistName };
tag.Title = fileName;
tag.Album = albumName;
tagFile.Save();
tagFile.Dispose();
writeStream.Dispose();
}
catch
{
}
i dont see any problem there, best thing to do now, is place breakpoints in the save() method and see which line is causing the issue. I cant reproduce this so i cant try this way.
But how would I know which line is causing the issue?
@IgorGiga sorry, what i meant was which line is taking 20 seconds to execute.
Ok! Will do that! I will get back to you once I have something new to share... If you came across any idea in the future on how to solve this problem, please feel free to let me know!
Hi! I am experiencing one problem while writing tags using taglib sharp portable in my winRT app. Writing works, but it takes 20 seconds to finish and app is frezzed during that time. Is this a bug or I am doing something wrong??? I will really appreciate any help!