How play a .mp3 (or other) file in a UWP app?
You cannot just read any file on your file system like this with windows store applications.
If you just want to test it:
- Add the file to your project in Visual Studio
- Change your file’s "Build Action" to "Content".
- Change "Copy to Output Directory" to "Copy Always".
What you probably want to do is explained in the section, Read Local files w/o a Picker from this article. This might also be helpful.
Every Windows Store App has three folders. A Local folder, a Roaming folder and a Temp folder. Each is accessed the same way. Local is meant to store assets in a local, application-specific folder.
Here is the answer:
StorageFolder Folder = Windows.ApplicationModel.Package.Current.InstalledLocation;
Folder = await Folder.GetFolderAsync("MyFolder");
StorageFile sf = await Folder.GetFileAsync("MyFile.mp3");
PlayMusic.SetSource(await sf.OpenAsync(FileAccessMode.Read), sf.ContentType);
PlayMusic.Play();
MfG.