Hi all,
I am very sad about what you are writing here. I work on the app all the time. To explain, why is was silent last days - when I wanted to do another batch of screenshots at the beginning last week, something wrong happened - all database data were coming back "scrambled". When the app music collection discovery finished, all tracks had less than a second long play time and genres like "18,a,9000000xxx". I could not believe my eyes, but it was everywhere. All files were returning these impossible values and the collection was completely unusable.
I have spend all my time since then trying to find a fix for this. I haven't changed any of the discovery code and haven't changed any project properties or anything that could have affected this. Even more crazy is the fact that this behavior now happened even with a completely blank new project and on all devices I have at home...
But it didn't stop there, even worse things happened when I tried to run the app in Release mode - which caused some kind of fatal error in Visual Studio 2013.
Long story short - now after more than a week of headaches I finally found out the causes for both of these issues.
To all developers who will attempt this in the future, here is what happened:
1) The Release mode not working
This one is a bug in the compilation process of Visual Studio when a portable class library contains localized RESX files. It works normally in debug mode, but once the release is switched on, the environment has problems compiling the localized resources and fails when it can't find the output in the build folder. The only solution is to use the localization via RESW files in the Universal Shared Project. This causes duplication of code if you intend to add other platforms later (Xamarin), but no other fix is available now as far as I know. For a sidenote, Windows Apps are okay for some reason and this problem doesn't affect them.
2) MusicProperties going mad
This one got me extremely unhappy. Not only the problem was very cryptic and impossible to debug, but the solution is even weirder. The issue here is caused by some kind of bug in Windows Phone 8.1 Runtime (I need to report this to the Windows Phone team somehow). To enumerate all music files from Music Library I was using the dedicated API - await KnownFolders.MusicLibrary.GetFilesAsync( CommonFileQuery.OrderByName ) - I normally got all music files (the whole file structure, of the music library), but couldn't query the valid values for Genre and Duration - or more precisely I could, but the values were all wrong). This problem must have started in the last Windows Phone updates somehow, because it worked flawlessly previously and it is present on both Developer Preview devices and Denim update devices.
The solution in the end is painfully simple but unpleasant at the same time. Instead of MusicLibrary API we have to use the normal folder traversing techniques: await folder.GetFilesAsync and folder.GetFoldersAsync. This solution is sadly much slower for large collections with complicated folder structure (because of the filesystem access broker process in the system each request has to go through adds additional time delay to initiate and return results), but for some reason, in this way, the properties are so far returning correctly. I couldn't get it working with any variation of the original code. I don't know the underlying reason for this... I will report it and hopefully it will get fixed in the future releases.
So this is what was keeping me busy... Now I finally know the "workaround solution" and will now rebuild the collection discovery code accordingly...
Thank you for your patience...
Sincerely
Martin Zikmund